Java Spring MVC应用程序映射上的NullPointerException
请帮助解决以下问题 我已经完成了一个简单的Spring MVC JSP应用程序,中间我遇到了下面的空指针异常,但是当我重新运行应用程序或有时需要我的管理服务重新启动时,这个异常将被清除,请告知 我只是试图从jsp提交我的登录表单,并得到这个错误Java Spring MVC应用程序映射上的NullPointerException,java,spring,jsp,spring-mvc,nullpointerexception,Java,Spring,Jsp,Spring Mvc,Nullpointerexception,请帮助解决以下问题 我已经完成了一个简单的Spring MVC JSP应用程序,中间我遇到了下面的空指针异常,但是当我重新运行应用程序或有时需要我的管理服务重新启动时,这个异常将被清除,请告知 我只是试图从jsp提交我的登录表单,并得到这个错误 java.lang.NullPointerException at com.sun.faces.context.ApplicationMap.get(ApplicationMap.java:97) at org.springframework.web.j
java.lang.NullPointerException
at com.sun.faces.context.ApplicationMap.get(ApplicationMap.java:97)
at org.springframework.web.jsf.FacesContextUtils.getWebApplicationContext(FacesContextUtils.java:51)
at org.springframework.web.jsf.FacesContextUtils.getRequiredWebApplicationContext(FacesContextUtils.java:81)
at org.springframework.web.jsf.el.SpringBeanFacesELResolver.getWebApplicationContext(SpringBeanFacesELResolver.java:90)
at org.springframework.web.jsf.el.SpringBeanFacesELResolver.getBeanFactory(SpringBeanFacesELResolver.java:78)
at org.springframework.beans.factory.access.el.SpringBeanELResolver.getValue(SpringBeanELResolver.java:50)
at com.sun.faces.el.DemuxCompositeELResolver._getValue(DemuxCompositeELResolver.java:176)
at com.sun.faces.el.DemuxCompositeELResolver.getValue(DemuxCompositeELResolver.java:203)
at com.sun.faces.el.ChainTypeCompositeELResolver.getValue(ChainTypeCompositeELResolver.java:94)
at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:188)
at javax.el.CompositeELResolver.getValue(CompositeELResolver.java:188)
at com.sun.el.parser.AstIdentifier.getValue(AstIdentifier.java:103)
at com.sun.el.parser.AstEmpty.getValue(AstEmpty.java:66)
at com.sun.el.parser.AstNot.getValue(AstNot.java:63)
at com.sun.el.ValueExpressionImpl.getValue(ValueExpressionImpl.java:224)
at weblogic.servlet.jsp.ELHelper.evaluate(ELHelper.java:32)
at jsp_servlet._web_45_inf._jsp.__usertodolist._jspService(__usertodolist.java:175)
at weblogic.servlet.jsp.JspBase.service(JspBase.java:34)
..........
UserToDoList_jsp.java
公共最终类UserToDoList_jsp扩展org.apache.jasper.runtime.HttpJspBase
实现org.apache.jasper.runtime.JspSourceDependent{
private static final JspFactory _jspxFactory = JspFactory.getDefaultFactory();
private static java.util.List<String> _jspx_dependants;
private org.apache.jasper.runtime.TagHandlerPool _jspx_tagPool_c_forEach_var_items;
private org.apache.jasper.runtime.TagHandlerPool _jspx_tagPool_form_select_tabindex_path_onchange;
private org.apache.jasper.runtime.TagHandlerPool _jspx_tagPool_c_set_value_target_property_nobody;
private org.apache.jasper.runtime.TagHandlerPool _jspx_tagPool_form_form_name_modelAttribute_method_action;
private org.apache.jasper.runtime.TagHandlerPool _jspx_tagPool_form_option_value_label_nobody;
private org.apache.jasper.runtime.TagHandlerPool _jspx_tagPool_c_if_test;
private org.apache.jasper.runtime.TagHandlerPool _jspx_tagPool_form_option_value_nobody;
private org.glassfish.jsp.api.ResourceInjector _jspx_resourceInjector;
public java.util.List<String> getDependants() {
return _jspx_dependants;
}
public void _jspInit() {
_jspx_tagPool_c_forEach_var_items = org.apache.jasper.runtime.TagHandlerPool.getTagHandlerPool(getServletConfig());
_jspx_tagPool_form_select_tabindex_path_onchange = org.apache.jasper.runtime.TagHandlerPool.getTagHandlerPool(getServletConfig());
_jspx_tagPool_c_set_value_target_property_nobody = org.apache.jasper.runtime.TagHandlerPool.getTagHandlerPool(getServletConfig());
_jspx_tagPool_form_form_name_modelAttribute_method_action = org.apache.jasper.runtime.TagHandlerPool.getTagHandlerPool(getServletConfig());
_jspx_tagPool_form_option_value_label_nobody = org.apache.jasper.runtime.TagHandlerPool.getTagHandlerPool(getServletConfig());
_jspx_tagPool_c_if_test = org.apache.jasper.runtime.TagHandlerPool.getTagHandlerPool(getServletConfig());
_jspx_tagPool_form_option_value_nobody = org.apache.jasper.runtime.TagHandlerPool.getTagHandlerPool(getServletConfig());
}
public void _jspDestroy() {
_jspx_tagPool_c_forEach_var_items.release();
_jspx_tagPool_form_select_tabindex_path_onchange.release();
_jspx_tagPool_c_set_value_target_property_nobody.release();
_jspx_tagPool_form_form_name_modelAttribute_method_action.release();
_jspx_tagPool_form_option_value_label_nobody.release();
_jspx_tagPool_c_if_test.release();
_jspx_tagPool_form_option_value_nobody.release();
}
public void _jspService(HttpServletRequest request, HttpServletResponse response)
throws java.io.IOException, ServletException {
PageContext pageContext = null;
HttpSession session = null;
ServletContext application = null;
ServletConfig config = null;
JspWriter out = null;
Object page = this;
JspWriter _jspx_out = null;
PageContext _jspx_page_context = null;
try {
response.setContentType("text/html;charset=UTF-8");
pageContext = _jspxFactory.getPageContext(this, request, response,
null, true, 8192, true);
_jspx_page_context = pageContext;
application = pageContext.getServletContext();
config = pageContext.getServletConfig();
session = pageContext.getSession();
out = pageContext.getOut();
_jspx_out = out;
_jspx_resourceInjector = (org.glassfish.jsp.api.ResourceInjector) application.getAttribute("com.sun.appserv.jsp.resource.injector");
out.write("\n");
out.write("\n");
out.write("\n");
out.write("\n");
out.write("\n");
out.write("\n");
out.write("\n");
out.write("\n");
out.write("\n");
out.write("<!DOCTYPE html>\n");
out.write("<html>\n");
out.write(" <head>\n");
out.write(" <title>Home</title>\n");
out.write(" <div class=\"inset\">\n");
out.write(" ");
out.print(session.getAttribute("dateTime"));
out.write("\n");
out.write(" <h2> TO DO LIST </h2> \n");
out.write(" ");
out.print(session.getAttribute("user"));
out.write("\n");
out.write(" <!-- <link href=\"style.css\" rel=\"stylesheet\" type=\"text/css\"/>\n");
out.write(" -->\n");
out.write(" <script type=\"text/javascript\">\n");
out.write("\n");
out.write(" function changeFunc($i) {\n");
out.write(" alert($i \"Please select Approve or Reject\");\n");
out.write(" }\n");
out.write(" </script> \n");
out.write(" </head> \n");
out.write(" <body>\n");
out.write(" <form action=\"logout\" method=\"POST\">\n");
out.write(" <button type=\"submit\">Logout</button> \n");
out.write(" </form> \n");
out.write("\n");
out.write(" <form name=\"Add\" action=\"Adduser\" method=\"post\">\n");
out.write(" <button type=\"submit\">ADD</button> \n");
out.write("\n");
out.write(" </form>\n");
out.write(" <form name=\"Modify\" action=\"Modifyuser\" method=\"post\">\n");
out.write(" <button type=\"submit\">Modify</button> \n");
out.write("\n");
out.write(" </form>\n");
out.write(" ");
// form:form
org.springframework.web.servlet.tags.form.FormTag _jspx_th_form_form_0 = (org.springframework.web.servlet.tags.form.FormTag) _jspx_tagPool_form_form_name_modelAttribute_method_action.get(org.springframework.web.servlet.tags.form.FormTag.class);
_jspx_th_form_form_0.setPageContext(_jspx_page_context);
_jspx_th_form_form_0.setParent(null);
_jspx_th_form_form_0.setMethod("POST");
_jspx_th_form_form_0.setName("TransactionAction");
_jspx_th_form_form_0.setModelAttribute("action");
_jspx_th_form_form_0.setAction("transactionAction");
int[] _jspx_push_body_count_form_form_0 = new int[] { 0 };
try {
int _jspx_eval_form_form_0 = _jspx_th_form_form_0.doStartTag();
if (_jspx_eval_form_form_0 != javax.servlet.jsp.tagext.Tag.SKIP_BODY) {
do {
out.write("\n");
out.write(" ");
// c:if
org.apache.taglibs.standard.tag.rt.core.IfTag _jspx_th_c_if_0 = (org.apache.taglibs.standard.tag.rt.core.IfTag) _jspx_tagPool_c_if_test.get(org.apache.taglibs.standard.tag.rt.core.IfTag.class);
_jspx_th_c_if_0.setPageContext(_jspx_page_context);
_jspx_th_c_if_0.setParent((javax.servlet.jsp.tagext.Tag) _jspx_th_form_form_0);
_jspx_th_c_if_0.setTest(((java.lang.Boolean) org.apache.jasper.runtime.PageContextImpl.evaluateExpression("${not empty ToDoList}", java.lang.Boolean.class, (PageContext)_jspx_page_context, null)).booleanValue());
int _jspx_eval_c_if_0 = _jspx_th_c_if_0.doStartTag();
if (_jspx_eval_c_if_0 != javax.servlet.jsp.tagext.Tag.SKIP_BODY) {
do {
out.write("\n");
out.write("\n");
out.write(" <table>\n");
out.write("\n");
out.write(" <tr> <th>ID</th>\n");
out.write(" <th>LOGIN ID</th>\n");
out.write(" <th>MAKER</th>\n");
out.write(" <th>TRANSACTION TYPE</th>\n");
out.write(" <th>STATUS</th>\n");
out.write(" </tr> \n");
out.write(" ");
// c:forEach
org.apache.taglibs.standard.tag.rt.core.ForEachTag _jspx_th_c_forEach_0 = (org.apache.taglibs.standard.tag.rt.core.ForEachTag) _jspx_tagPool_c_forEach_var_items.get(org.apache.taglibs.standard.tag.rt.core.ForEachTag.class);
_jspx_th_c_forEach_0.setPageContext(_jspx_page_context);
_jspx_th_c_forEach_0.setParent((javax.servlet.jsp.tagext.Tag) _jspx_th_c_if_0);
_jspx_th_c_forEach_0.setVar("item");
_jspx_th_c_forEach_0.setItems((java.lang.Object) org.apache.jasper.runtime.PageContextImpl.evaluateExpression("${ToDoList}", java.lang.Object.class, (PageContext)_jspx_page_context, null));
int[] _jspx_push_body_count_c_forEach_0 = new int[] { 0 };
try {
int _jspx_eval_c_forEach_0 = _jspx_th_c_forEach_0.doStartTag();
if (_jspx_eval_c_forEach_0 != javax.servlet.jsp.tagext.Tag.SKIP_BODY) {
do {
out.write("\n");
out.write(" <tr>\n");
out.write(" <td> <input value=\"");
out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.evaluateExpression("${item[0]}", java.lang.String.class, (PageContext)_jspx_page_context, null));
out.write("\" type=\"number\" name=\"id\" readonly /></td>\n");
out.write(" <td> <input value=\"");
out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.evaluateExpression("${item[1]}", java.lang.String.class, (PageContext)_jspx_page_context, null));
out.write("\" type=\"text\" name=\"loginId\" readonly /></td>\n");
out.write(" <td> <input value=\"");
out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.evaluateExpression("${item[2]}", java.lang.String.class, (PageContext)_jspx_page_context, null));
out.write("\" type=\"text\" name=\"maker\" readonly /></td>\n");
out.write(" <td> <input value=\"");
out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.evaluateExpression("${item[3]}", java.lang.String.class, (PageContext)_jspx_page_context, null));
out.write("\" type=\"text\" name=\"transactionType\" readonly /></td>\n");
out.write(" <td> <input value=\"");
out.write((java.lang.String) org.apache.jasper.runtime.PageContextImpl.evaluateExpression("${item[4]}", java.lang.String.class, (PageContext)_jspx_page_context, null));
out.write("\" type=\"text\" name=\"status\" readonly /></td>\n");
out.write(" <td>\n");
out.write(" ");
// form:select
...
}
上述异常发生在usertodolist.jsp中。NPE是由空键引起的,因此这意味着EL中的某些内容计算为空。如果为空,则错误应该是一致的,但在我的情况下,它是间歇性的。不一定。环境中可能会有变化。您可以查看usertodolist并发布EL代码或eve吗n fetch _usertodolist.java并查看第175行添加的usertodolist _jsp.java,请帮助有一些调用evaluateExpression${item[0]}但是没有调用进行求值。我不确定是否是发布的文件导致的。堆栈跟踪中提到的类是uu usertodolist,您发布的usertodolist\u jspy您真的不应该这样比较字符串。您应该尝试成功。equalsresult。@Makoto谢谢您的建议,我已经相应地更改了。请在中间提供建议注意力不集中的NPE