Get parameters from URL under portal enviroment on

2019-07-25 06:11发布

问题:

I want to get parameter from a URL under portlet environment. The URL i am using to open a portlet is http://localhost:10039/wps/myportal/myPortlet?recId=100

When the portlet opens the URL changes and looks like *http://localhost:10039/wps/myportal/myPortlet/!ut/p/b1/dY7LcoIwAAC_hQ9wElQSckwJ8lLEgjxyYbDTBAQMgkXHr7ft9Nq97cweFnBQmEhfGUtMdJADfqnmRla3Rl2q7sc5Kt_I0d1RxCCOyAZ6EQl8a29CSA3gAy47dfpOU1aoB1NUMsrEerIUz7lu0vma1pY9hNTZRbXZx8jYP8-SBSv_OibxLD66fnwvknYom9xPMzkK9awT_3Ru6i8Wt5SLA7GDTXtPt5OdGYMkd2wnDorD6UHKm8SqrwpRCb6YD5oGMsB_ly2Humu8hdA0TB161D1iFLMlpKu_AP4DhSB0Vf8Jeu4Qb0G1F8FgaxU!/dl4/d5/L2dBISEvZ0FBIS9nQSEh/?recId=100*

The actuall thing is I want to get recID=100 parameter. The code i am using to get parameter is given below

PortletRequest portletRequest = (PortletRequest) webAppAccess.getHttpServletRequest().getAttribute( Constants.PORTLET_REQUEST);
HttpServletRequest httpRequest = PortletUtils.getInternalRequest(portletRequest).getHttpServletRequest();                   
httpRequest.getParameter("recId");

but it returns null

Can anyone help me how can i get the parameter under the given situation?

Note : I am using WebSphere Portal Server 7.

回答1:

Well, its not that easy.

You have to generate specific urls. WebSphere Portal Advanced Url Generation and How to create a link to a portlet and pass parameters.



回答2:

I had this scenario before, and someone suggested me to use Portlet utilities, you can find this class in "com.ibm.ws.portletcontainer.portlet" pakcage, there are a lot of constructors(RenderRequest, ActionRequest, PortletRequest, ...), this is the method(PortletUtils.getHttpServletRequest(YOUR NEEDED OBJECT)) you can find your needs.