站内搜索: 请输入搜索关键词

当前页面: 开发资料首页J2EE 专题action里调spring配置的bean居然是null.

action里调spring配置的bean居然是null.

摘要: action里调spring配置的bean居然是null.


我在action里也有get,set这个bean的方法,然后我 spring配置文件里也配置好了,把这个bean注入到了action






为什么我在用的时候,这个user是null!!?是什么原因??


发现没人用spring了,都没人知道吗?




你需要在web.xml里面对你要使用到的bean进行一个初始化


contextConfigLocation

/WEB-INF/config/data.xml /WEB-INF/config/service.xml




org.springframework.web.context.ContextLoaderListener




你有没有在STRUTS有没有把不的ACTION交给SPRING来处理呢/?
应该是这个原因的



1.在struts-config.xml里加Plugin




2.在applicationContext.xml里实例Action如LZ所做
3.在struts-config.xml里配置Action
path一定要为spring中实例好的Action的name
必须要有type="org.springframework.web.struts.DelegatingActionProxy"

参考
http://www-128.ibm.com/developerworks/java/library/j-sr2.html?ca=drs-tp4105


↑返回目录
前一篇: 输入邮件,进行订阅,如何做?
后一篇: Java建立Zip压缩文件