下面程序错误,麻烦帮忙看看怎么解决?还有什么需要的请各位大侠提出来

严重: 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>


海绵宝宝撒
浏览 74回答 2
2回答

ibeautiful

这个错误只能说明这个action在第43执行时出错了,具体什么错误应该贴出代码才能看的出java.lang.NullPointerException,只能说明某个变量为空,如session&nbsp;你的PersonDAO 注主sessionFactory了吗,applicationContext有配置没有?

波斯汪

空指针的使用,这里很难看出问题,给全代码来看看
打开App,查看更多内容
随时随地看视频慕课网APP