日期:2014-05-17  浏览次数:20664 次

error分析,求大虾
由index.jsp 跳转到 save.jsp 除此错,地址栏显示是正确的localhost:8080/struts/index.jsp to localhost:8080/struts/save.jsp
type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jasper.JasperException: java.lang.NullPointerException
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:538)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:430)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:413)

root cause

java.lang.NullPointerException
org.apache.struts2.components.UIBean.evaluateParams(UIBean.java:746)
org.apache.struts2.components.UIBean.end(UIBean.java:481)
org.apache.struts2.views.jsp.ComponentTagSupport.doEndTag(ComponentTagSupport.java:43)
org.apache.jsp.save_jsp._jspx_meth_s_005ftextfield_005f0(save_jsp.java:162)
org.apache.jsp.save_jsp._jspx_meth_s_005fform_005f0(save_jsp.java:117)
org.apache.jsp.save_jsp._jspService(save_jsp.java:79)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:388)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:313)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:260)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.apache.struts2.dispatcher.FilterDispatcher.doFilter(FilterDispatcher.java:413)

note The full stack trace of the root cause is available in the Apache Tomcat/6.0.33 logs.
Apache Tomcat/6.0.33

------解决方案--------------------
java.lang.NullPointerException
空指针异常
org.apache.jsp.save_jsp._jspx_meth_s_005ftextfield_005f0(save_jsp.java:162)
org.apache.jsp.save_jsp._jspx_meth_s_005fform_005f0(save_jsp.java:117)
org.apache.jsp.save_jsp._jspService(save_jsp.java:79)
你好好检查一下save页面参数的值
------解决方案--------------------
user对象是空的吧。
------解决方案--------------------
User user=new User() 實例化
------解决方案--------------------
为user加一个空的构造方法,否则struts无法帮你实例化,当然你也可以自己new一个出来
------解决方案--------------------
探讨

我把user.firstname 改成 firstname 还是有问题

<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<……

------解决方案--------------------
UserService service 有可能为空。用debug呀
------解决方案--------------------
对付空指针 一直觉得好办法就是把可能空的地方断点 debug一下

可以看api
我的异常网推