【问题标题】:Get parameters from URL under portal enviroment on WPS7WPS7门户环境下从URL获取参数
【发布时间】:2011-11-11 16:06:19
【问题描述】:

我想在portlet 环境下从URL 获取参数。 我用来打开 portlet 的 URL 是 http://localhost:10039/wps/myportal/myPortlet?recId=100

当 Portlet 打开时,URL 会发生变化,看起来像 * HTTP://本地主机:10039 / WPS / myportal /时,MyPortlet / UT / P / B1 / dY7LcoIwAAC_hQ9wElQSckwJ8lLEgjxyYbDTBAQMgkXHr7ft9Nq97cweFnBQmEhfGUtMdJADfqnmRla3Rl2q7sc5Kt_I0d1RxCCOyAZ6EQl8a29CSA3gAy47dfpOU1aoB1NUMsrEerIUz7lu0vma1pY9hNTZRbXZx8jYP8-SBSv_OibxLD66fnwvknYom9xPMzkK9awT_3Ru6i8Wt5SLA7GDTXtPt5OdGYMkd2wnDorD6UHKm8SqrwpRCb6YD5oGMsB_ly2Humu8hdA0TB161D1iFLMlpKu_AP4DhSB0Vf8Jeu4Qb0G1F8FgaxU / DL4 / D5 / L2dBISEvZ0FBIS9nQSEh / recId = 100 * P>!?

实际是我想得到 recID=100 参数。下面给出了我用来获取参数的代码

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

但它返回 null

谁能帮助我在给定情况下如何获取参数?

注意: 我正在使用 WebSphere Portal Server 7。

【问题讨论】:

    标签: websphere-7 websphere-portal


    【解决方案1】:

    嗯,没那么容易。

    您必须生成特定的网址。 WebSphere Portal Advanced Url GenerationHow to create a link to a portlet and pass parameters.

    【讨论】:

      【解决方案2】:

      我之前有过这种情况,有人建议我使用Portlet实用程序,你可以在“com.ibm.ws.portletcontainer.portlet”包中找到这个类,有很多构造函数(RenderRequest,ActionRequest,PortletRequest, ...),这就是你可以找到你需要的方法(PortletUtils.getHttpServletRequest(YOUR NEEDED OBJECT))。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-03-17
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多