我已經定義了一個由我的六個Portlet組成的頁面,並將portal-ext.properties
文件配置爲我的默認頁面頁面。Liferay:如何在Liferay中使用RequestDispatcher重定向到公共頁面
我有一個自定義登錄頁面接觸到我的數據庫,一旦用戶是有效的,我使用/用戶/測試/家重定向他此頁,並且還使用http://localhost:8086/user/test/home
試圖但這並沒有奏效,我一直在得到
public void doView(RenderRequest request, RenderResponse response)
throws PortletException, IOException {
response.setContentType("text/html");
System.out.println("Inside the doView Method");
PortletRequestDispatcher dispatcher = null;
if (this.name.isEmpty()) {
dispatcher = getPortletContext().getRequestDispatcher(
"/WEB-INF/jsp/AllInOne_view.jsp");
} else {
request.setAttribute("name", this.name);
dispatcher = getPortletContext().getRequestDispatcher(
"http://localhost:8086/user/test/home");
}
this.name = "";
this.action = "";
dispatcher.include(request, response);
}
17:53:47,765 ERROR [render_portlet_jsp:154] java.lang.NullPointerException
at org.ravi.learning.AllInOne.doView(AllInOne.java:57)
at javax.portlet.GenericPortlet.doDispatch(GenericPortlet.java:328)
at javax.portlet.GenericPortlet.render(GenericPortlet.java:233)
at com.liferay.portlet.FilterChainImpl.doFilter(FilterChainImpl.java:100)
at com.liferay.portal.kernel.portlet.PortletFilterUtil.doFilter(PortletFilterUtil.java:64)
at com.liferay.portal.kernel.servlet.PortletServlet.service(PortletServlet.java:93)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
的AllinOne.java是我的自定義GenericPortlet類AllInOne.java:57是
dispatcher.include(request, response);
更新部分這裏
這是Java類
package org.ravi.learning;
import java.io.IOException;
import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.GenericPortlet;
import javax.portlet.PortletException;
import javax.portlet.PortletRequestDispatcher;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
public class AllInOne extends GenericPortlet {
String action = "";
String name = "";
public void processAction(ActionRequest request, ActionResponse response)
throws PortletException, IOException {
System.out.println("Inside the Process Action Method new");
this.action = request.getParameter("myAction");
if (this.action.equals("formAction")) {
this.name = request.getParameter("personName");
}
String urlpaths = "http://localhost:8086/user/test/home";
response.sendRedirect(urlpaths);
}
public void doView(RenderRequest request, RenderResponse response)
throws PortletException, IOException {
response.setContentType("text/html");
}
}
作爲一個新的用戶,我不能發表圖片,請參閱該圖像
http://tinypic.com/view.php?pic=a43nlv&s=5
Is getPortletContext()是否返回對象?只需打印並查看返回結果 – 2012-04-10 05:46:07
如果我使用存在的JSP文件getPortletContext()。getRequestDispatcher進入它,此工作正常,但在此處我使用默認登錄頁面,並且它向我拋出此錯誤。那麼請告訴我,如果使用默認登陸頁面這種方式是正確的? – Gajjini 2012-04-10 10:09:04
@ user1318607在日誌中有什麼有趣的地方? – soulcheck 2012-04-11 10:44:21