setAttr("user", user); render("index.jsp"); 后jsp ${user.name} 取值报空指针

严重: Servlet.service() for servlet jsp threw exception

java.lang.NullPointerException

at java.util.Objects.requireNonNull(Objects.java:203)

at javax.el.CompositeELResolver.add(CompositeELResolver.java:47)

at org.apache.jasper.el.JasperELResolver.add(JasperELResolver.java:70)

at org.apache.jasper.el.JasperELResolver.<init>(JasperELResolver.java:58)

at org.apache.jasper.runtime.JspApplicationContextImpl.createELResolver(JspApplicationContextImpl.java:115)

at org.apache.jasper.runtime.JspApplicationContextImpl.createELContext(JspApplicationContextImpl.java:88)

at org.apache.jasper.runtime.PageContextImpl.getELContext(PageContextImpl.java:950)

at org.apache.jasper.runtime.PageContextImpl.proprietaryEvaluate(PageContextImpl.java:935)

at org.apache.jsp.core.login.index_jsp._jspService(index_jsp.java:332)

at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:443)

at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385)

at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:729)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:230)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)

at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192)

at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165)

at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:726)

at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:469)


评论区

JFinal

2019-04-22 19:26

NPE 单步调试分分钟解决,找到那个为 null 值的对象即可

JSP 是上古时代的产物,扔了吧

热门反馈

扫码入社