当我的 Spring 控制器方法尝试将控制权传递给 JSP 时,我收到以下错误消息。
java.lang.NullPointerException
at org.apache.jsp.WEB_002dINF.pages.PollPage_jsp._jspService(PollPage_jsp.java:202)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:432)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:684)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:471)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:402)
at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:329)
at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)
at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:262)
at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1265)
at org.springframework.web.servlet.DispatcherServlet.processDispatchResult(DispatcherServlet.java:1016)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:965)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:859)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:883)
at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:781)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:621)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100)
at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:562)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:395)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:250)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:188)
at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:302)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
这是我的控制器的相关部分。
@RequestMapping(value = "/polls")
public String polls(Model model, HttpServletRequest request) {
// processing that's not relevant to the problem
return "PollPage";
}
这是我的 JSP 代码。
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib prefix="myTag1" uri="poll1"%>
<%@ taglib prefix="myTag2" uri="poll2"%>
<%@ taglib prefix="myTag3" uri="poll3"%>
<c:set var="foundCookiePoll1" value="false" scope="page" />
<c:set var="foundCookiePoll2" value="false" scope="page" />
<c:set var="foundCookiePoll3" value="false" scope="page" />
<c:set var="poll1Yes" value="0" scope="page" />
<c:set var="poll1No" value="0" scope="page" />
<c:set var="poll2Job" value="0" scope="page" />
<c:set var="poll2School" value="0" scope="page" />
<c:set var="poll2Married" value="0" scope="page" />
<c:set var="poll2Crazy" value="0" scope="page" />
<c:set var="poll3zero" value="0" scope="page" />
<c:set var="poll3one" value="0" scope="page" />
<c:set var="poll3two" value="0" scope="page" />
<c:set var="poll3three" value="0" scope="page" />
<c:set var="poll3morethanthree" value="0" scope="page" />
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Poll Page</title>
<style type="text/css">
p {
text-align: justify;
}
</style>
</head>
<body>
<%
Cookie[] cookies = request.getCookies();
if (cookies != null) {
for (int i = 0; i < cookies.length; i++) {
if (cookies[i].getName().equals("poll1")) {
%> <c:set var="foundCookiePoll1" value="true" /> <%
}
if (cookies[i].getName().equals("poll2")) {
%> <c:set var="foundCookiePoll2" value="true" /> <%
}
if (cookies[i].getName().equals("poll3")) {
%> <c:set var="foundCookiePoll3" value="true" /> <%
}
}
}
int poll1Yes = (Integer) request.getAttribute("poll1Yes");
int poll1No = (Integer) request.getAttribute("poll1No");
int poll2Job = (Integer) request.getAttribute("poll2Job");
int poll2School = (Integer) request.getAttribute("poll2School");
int poll2Married = (Integer) request.getAttribute("poll2Married");
int poll2Crazy = (Integer) request.getAttribute("poll2Crazy");
int poll3zero = (Integer) request.getAttribute("poll3zero");
int poll3one = (Integer) request.getAttribute("poll3one");
int poll3two = (Integer) request.getAttribute("poll3two");
int poll3three = (Integer) request.getAttribute("poll3three");
int poll3morethanthree = (Integer) request.getAttribute("poll3morethanthree");
%>
<center>
<h1>Granada High School Class of 1986 Poll Page</h1>
</center>
<!-- main content of page -->
</body>
</html>
当我在 Eclipse 中单步执行控制器代码时,我收到以下消息:
The source attachment does not contain the source for the file InvocationHandlerMethod.class
当我收到另一条消息时会发生这种情况:
NativeMethodAccessorImpl.invoke(Object, Object[] line: not available
任何人都可以对此有所了解吗?我在想我可能缺少一个 jar 文件。