问题
<%
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