【发布时间】:2013-03-27 21:24:39
【问题描述】:
我已经定义了一个由我的六个 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类
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");
}
}
作为一个新用户,我无法发布图片,所以请参考此外部链接获取图片
【问题讨论】:
-
getPortletContext() 是否返回一个对象?只需打印并查看它返回的内容
-
如果我在其中使用现有的 JSP 文件 getPortletContext().getRequestDispatcher,这可以正常工作,但这里我使用的是默认登录页面,它会抛出这个错误。那么请告诉我以这种方式使用默认着陆页是否正确??
-
@user1318607 日志中有什么有趣的吗?