URL Parameters in Portlets

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

0 archivos adjuntos
26594 Accesos
Promedio (2 Votos)
La valoración media es de 5.0 estrellas de 5.