我已经定义了一个由我的六个Portlet组成的页面,并在portal-ext.properties
文件中将其配置为我的默认Lnding页面。
我有一个用于联系我的数据库的自定义登录页面,一旦用户有效,我将使用/ user / test / home将他重定向到此页面并尝试使用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是我的Custom GenericPortlet类AllInOne.java:57是
dispatcher.include(request, response);
此处更新了部分
这是java Class
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");
}
}
作为新用户,我无法发布图片,因此请参阅此外部链接以获取图片
答案 0 :(得分:2)
根据PortletContext.getRequestDispatcher()的jsr168和jsr286文档,
路径名必须以斜杠(/)开头,并被解释为 相对于当前的上下文根。
因此使用"http://localhost:8086/user/test/home"
作为参数是错误的。
您可能想要做的是重定向。在portlet环境中,您只能使用ActionResponse.sendRedirect(String)