0

I'm trying to change the title of the page, but the method PortalUtil.setPageTitle("title", request); is not working from the jsp. I also tried in the doView method.

My second attempt was throught servletrequest:

In doView I wrote

HttpServletRequest httpRequest = PortalUtil.getOriginalServletRequest(PortalUtil.getHttpServletRequest(renderRequest));
httpRequest.setAttribute("hola", "hola");

And in the portal normal I tried with:

#set ($holas =$request.get('attributes').get('hola'))
#set ($holas2 = $request.getSession().getAttribute("hola"))

$holas    
$holas2

but Velocity only shows $holas $holas2.

4

3 回答 3

1

看起来我在第一次尝试时弄错了 - 因此我用这个答案替换了以前的答案:将此代码添加到您的 JSP 或 doView:

<% 
com.liferay.portal.util.PortalUtil.setPageTitle("Honk", request); 
%>
于 2013-07-09T07:57:27.363 回答
0

在你的jsp中你应该尝试

<%
layout.setTitle("title");
%>

layout是jsp生成的一个Layout对象。

于 2013-07-30T10:53:51.937 回答
0

使用下面的代码,

String title = (String)renderRequest.getAttribute("title");
HtmlPageTitleUtil.setHtmlTitle(title, request, true);

从控制器传递标题属性,或者您也可以使用静态文本。导入上述实用程序类以及,

<portlet:defineObjects />
<theme:defineObjects />

这到 jsp 并完成。

于 2015-10-01T11:36:57.893 回答