URL Parameters in Portlets

Introduction #

This article describes how to grab variables passed in through url parameters, from within a portlet.

Example: http://whatever.com/page?param=something

PortalUtil #

Normally your portlet does not have access to this parameter! This is because, by default, the requests passed to your portlets are namespaced and portlets only have access to their namespaced parameters.

You can still grab them easily though if you want to by doing this:

  • In a JSP: 

String param = PortalUtil.getOriginalServletRequest(request).getParameter("param");

  • In a portlet render:

HttpServletRequest request = PortalUtil.getHttpServletRequest(renderRequest);String param = PortalUtil.getOriginalServletRequest(request).getParameter("param");

0 添付ファイル
30679 参照数
平均 (2 投票)
平均評価は5.0星中の5です。
コメント