struts2与spring整合时,报空指针NullPointerException异常的解决
2012-04-22 17:18
381 查看
下午写了ssh的测试程序,但是最后在运行时,Action里面的service总是注入不进来,提示NullPointerException异常。仔细一看错误提示,肯定是没有注入进来。就比较郁闷了。花了一个下午时间,终于解决了。
原来是:
在spring配置文件中对于action的配置,假设id是useraction,那么在struts.xml中,不应该还是像以前单独用struts时那样,而是将在struts.xml中action的class=useraction。也就是:
将struts.xml中的action的class属性,由class名改为Spring中定义的bean的id名。问题解决!
原来是:
在spring配置文件中对于action的配置,假设id是useraction,那么在struts.xml中,不应该还是像以前单独用struts时那样,而是将在struts.xml中action的class=useraction。也就是:
将struts.xml中的action的class属性,由class名改为Spring中定义的bean的id名。问题解决!
相关文章推荐
- JavaWeb学习(5.5)---在Servlet使用getServletContext()获取ServletContext对象出现java.lang.NullPointerException(空指针)异常的解决办法
- 在Servlet使用getServletContext()获取ServletContext对象出现java.lang.NullPointerException(空指针)异常的解决办法
- 在Servlet使用getServletContext()获取ServletContext对象出现java.lang.NullPointerException(空指针)异常的解决办法
- 在Servlet使用getServletContext()获取ServletContext对象出现java.lang.NullPointerException(空指针)异常的解决办法
- Spring异常解决 java.lang.NullPointerException,配置spring管理hibernate时出错
- EJB注入后的空指针异常(NullPointerException)解决办法
- atitit.解决struts2 SpringObjectFactory.getClassInstance NullPointerException
- 在Servlet使用getServletContext()获取ServletContext对象出现java.lang.NullPointerException(空指针)异常的解决办法
- 在Servlet使用getServletContext()获取ServletContext对象出现java.lang.NullPointerException(空指针)异常的解决办法
- atitit.解决struts2 SpringObjectFactory.getClassInstance NullPointerException
- 在Servlet使用getServletContext()获取ServletContext对象出现java.lang.NullPointerException(空指针)异常的解决办法
- 在Servlet使用getServletContext()获取ServletContext对象出现java.lang.NullPointerException(空指针)异常的解决办法
- 在Servlet使用getServletContext()获取ServletContext对象出现java.lang.NullPointerException(空指针)异常的解决办法
- 在Servlet使用getServletContext()获取ServletContext对象出现java.lang.NullPointerException(空指针)异常的解决办法
- 在Servlet使用getServletContext()获取ServletContext对象出现java.lang.NullPointerException(空指针)异常的解决办法
- 在Servlet使用getServletContext()获取ServletContext对象出现java.lang.NullPointerException(空指针)异常的解决办法
- spring struts2 整合 action 注入service 报错NullPointerException
- 在Servlet使用getServletContext()获取ServletContext对象出现java.lang.NullPointerException(空指针)异常的解决办法
- Struts2中使用execAndWait后,在 Action中调用getXXX()方法报告java.lang.NullPointerException异常的原因和解决方法
- Struts2和Spring整合:NullPointerException