how do redirect in LIFERAY from first.jsp on second.jsp?

半城伤御伤魂 提交于 2019-12-24 19:06:49

问题


<%
if(my_value==true){
//redirect to page second.jsp
}
%>

How do this? please help me in this questions


回答1:


The redirection inside of jsp isn't realy expedient idea, because jsp-parsing below to render phase and this phase is concepted to show the content.

On the other hand redirection below to action phase, here you can decide what the portlet should do at next.

Read this tutorial for better understanding the two-phase of portlet: http://www.liferay.com/documentation/liferay-portal/6.0/development/-/ai/understanding-the-two-phases-of-portlet-execution

Hence, put redirection in portlet processAction methode:

@Override
public void processAction(ActionRequest actionRequest, ActionResponse actionResponse) throws IOException, PortletException {
    //defaultLandingPage = ...
    actionResponse.sendRedirect(defaultLandingPage);
};

Else, if you realy want to do this inside of jsp, you can include second jsp in the first jsp:

<liferay-util:include page="second.jsp" />



回答2:


 <portlet:renderURL var="other">
  <portlet:param name="jspPage" value="/jsp/b.jsp"/>
  </portlet:renderURL>
  <a href="<%=other%>">other</a>



回答3:


response.sendRedirect("");

Note that the path can be relative, absolute or relative to the server root. Also, it won't work if the response has already been committed.



来源:https://stackoverflow.com/questions/10562050/how-do-redirect-in-liferay-from-first-jsp-on-second-jsp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!