严重: Servlet.service() for servlet default threw exception
java.lang.NullPointerException
at service.LoginAction.execute(LoginAction.java:43)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
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)
public class LoginAction extends ActionSupport{
private String username;
private String password;
private PersonDAO personManager;
/*其中的seter和geter方法省略了*/
@Override
public String execute() throws Exception {
String flag = "";
Person per = new Person();
per.setUname(this.username);
per.setUpwd(this.password);
personManager.save(per);
return flag;
}
}
save函数的的代码
public class PersonDAO extends HibernateDaoSupport{
public void save(Person transientInstance) {
log.debug("saving Person instance");
try {
getHibernateTemplate().save(transientInstance);
log.debug("save successful");
} catch (RuntimeException re) {
log.error("save failed", re);
throw re;}
}
还有什么需要的请各位大侠提出来谢谢诶
<bean id="PersonDAO" class="user.PersonDAO"><property name="sessionFactory"><ref bean="sessionFactory" /></property>
ibeautiful
波斯汪