Portlet 可以读取其周围页面的请求参数吗?
例如,portlet 所在页面的 URL 是http://example.com/mypage?foo=bar 是否可以从该页面上的 portlet 中读取“foo”参数?
Portlet 容器是 Liferay 5.2.5。
Portlet 可以读取其周围页面的请求参数吗?
例如,portlet 所在页面的 URL 是http://example.com/mypage?foo=bar 是否可以从该页面上的 portlet 中读取“foo”参数?
Portlet 容器是 Liferay 5.2.5。
是的,这可以通过这样的方式来实现 -
HttpServletRequest convertReq = PortalUtil.getHttpServletRequest(request);
HttpServletRequest originalReq = PortalUtil.getOriginalServletRequest(convertReq);
String productId = originalReq.getParameter("foo");
其中 request 是 RenderRequest。
PortletRequest
类有方法getAttribute()
你可以把它当作HttpServletRequest
.
除了使用特定于平台的类之外,我还没有找到其他方法com.liferay.portal.util.PortalUtil
。