严重: Servlet.service() for servlet default threw exceptionjava.lang.NullPointerExceptionat 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>
2 回答
ibeautiful
TA贡献1993条经验 获得超5个赞
这个错误只能说明这个action在第43执行时出错了,具体什么错误应该贴出代码才能看的出
java.lang.NullPointerException,只能说明某个变量为空,如session
你的PersonDAO 注主sessionFactory了吗,applicationContext有配置没有?
- 2 回答
- 0 关注
- 73 浏览
添加回答
举报
0/150
提交
取消