文档详情

Struts的action自动装配到spring.doc

发布:2016-05-19约1.35万字共9页下载文档
文本预览下载声明
Struts在与Spring整合是要实现Struts的action自动装配到spring容器中,我们经常遇到的问题是:java.lang.NullPointException这个空指针异常,我碰到的有这么几种解决方案: 1.看一下你的set方法是否存在。 2.是否在web.xml中配置了“当web项目启动的时候,让spring扫描整个项目。”,当然也要加上一个名为:struts-spring-plugin***.jar的包,这个包实现了action装配到spring的功能。(如果已经加了这个包,也配置了web.xml还出现空指针异常,那么可能是你的struts-spring-plugin***.jar的版本不配套,还几个版本试试) web.xml中添加的配置(添加在Struts配置的前面): [html]?view plaincopy span?style=font-size:24px;??listener?? ????????listener-classorg.springframework.web.context.ContextLoaderListener/listener-class?? ????/listener?? ????context-param?? ?????????param-namecontextConfigLocation/param-name?? ?????????param-valueclasspath:bean.xml/param-value?? ????/context-param/span?? 当你已经完成上面描述的配置的时候,还可能出现下面的这个异常,异常信息如下(这个是浏览器报的异常,后台没有异常,服务器启动正常): [plain]?view plaincopy span?style=font-size:24px;Struts?Problem?Report?? ?? Struts?has?detected?an?unhandled?exception:?? ?? Messages:????? Cannot?convert?value?of?type?[xy.$Proxy8?implementing?com.zsq.wxssh.service.UserService,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised]?to?required?type?[com.zsq.wxssh.serviceimpl.UserServiceImpl]?for?property?userServiceImpl:?no?matching?editors?or?conversion?strategy?found?? Failed?to?convert?property?value?of?type?[xy.$Proxy8?implementing?com.zsq.wxssh.service.UserService,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised]?to?required?type?[com.zsq.wxssh.serviceimpl.UserServiceImpl]?for?property?userServiceImpl;?nested?exception?is?java.lang.IllegalArgumentException:?Cannot?convert?value?of?type?[xy.$Proxy8?implementing?com.zsq.wxssh.service.UserService,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised]?to?required?type?[com.zsq.wxssh.serviceimpl.UserServiceImpl]?for?property?userServiceImpl:?no?matching?editors?or?conversion?strategy?found?? Unable?to?instantiate?Action,?com.zsq.wxssh.action.LoginAction,?defined?for?Login?in?namespace?/Failed?to?convert?property?value?of?type?[xy.$Proxy8?implementing?com.zsq.wxssh.
显示全部
相似文档