我已经定义了一个由我的六个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