Get parameters from URL under portal enviroment on WPS7

巧了我就是萌 提交于 2019-12-11 08:19:30

问题


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.



来源:https://stackoverflow.com/questions/8096725/get-parameters-from-url-under-portal-enviroment-on-wps7

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!