当前位置: 代码迷 >> J2EE >> 严重: Servlet.service() for servlet default threw exception
  详细解决方案

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

热度:569   发布时间:2016-04-22 00:52:17.0
严重: Servlet.service() for servlet default threw exception 求救
严重: Servlet.service() for servlet default threw exception
java.lang.NullPointerException
at org.bookstore.action.UserAction.register(UserAction.java:22)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeAction(DefaultActionInvocation.java:404)
at com.opensymphony.xwork2.DefaultActionInvocation.invokeActionOnly(DefaultActionInvocation.java:267)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:229)
at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:221)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:86)
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:224)
at com.opensymphony.xwork2.DefaultActionInvocation$2.doProfiling(DefaultActionInvocation.java:223)
at com.opensymphony.xwork2.util.profiling.UtilTimerStack.profile(UtilTimerStack.java:455)





UserAction类里是这样子

  public String register()throws Exception{
System.out.println(usertable.getUsername());
UserTable usertable1=new UserTable();
usertable1.setUsername(usertable.getUsername());
usertable1.setAge(usertable.getAge());
usertable1.setPassword(usertable.getPassword());
usertable1.setSex(usertable.getSex());
userService.saveUserTable(usertable1);
 
return SUCCESS;
  }
调试在 System.out.println(usertable.getUsername());
就出错

UserTable类里值这样子

public class UserTable implements java.io.Serializable {

// Fields

private Integer userid;
private String username;
private String password;
private String sex;
private Integer age;
  private Set orderses=new HashSet(0);


------解决方案--------------------
空指针异常 
usertable.getUsername()
usertable 在哪里实例的?

------解决方案--------------------
UserTable没创建get、set方法?
------解决方案--------------------
usertable这个是哪来的?
都没有setUsertable方法,这个肯定是空的
  相关解决方案