URL Parameters in Portlets

(Redirigé depuis Grabbing url parameters parameters from portlets)
Étiquettes: liferay v5.2 parameter

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");

Moyenne (2 Voter)
L'estimation moyenne est de 5.0 étoiles sur 5.
Commentaires