《2023年Strutsaction自动装配到spring(全文完整).docx》由会员分享,可在线阅读,更多相关《2023年Strutsaction自动装配到spring(全文完整).docx(15页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、2023年Strutsaction自动装配到spring(全文完整)下面是我为大家整理的Strutsaction自动装配到spring(全文完整),供大家参考。Struts 在与 Spring 整合是要实现 Struts 的 action 自动装配到 spring 容器中, 我们经常遇到的问题是:java.lang.NullPointException 这个空指针异常, 我碰到的有这么几种解决方案:1 .看一下你的 set 方法是否存在。2.是否在 web.xml 中配置了当 web 项目启动的时候,让 spring 扫描整个项目。, 当然也要加上一个名为:struts-spring-plug
2、in*.jar 的包, 这个包实现了 action装配到 spring 的功能。(如果已经加了这个包, 也配置了 web.xml 还出现空指针异常, 那么可能是你的struts-spring-plugin*.jar 的版本不配套, 还几个版本试试)web.xml 中添加的配置(添加在 Struts 配置的前面): h t m l view plaincopy 1.lt;span style=font-size: 24px; gt;lt;listenergt; 2.lt;listener-classgt;org. springframework. web. context. ContextLoa
3、derListenerlt;/listener-classgt; 3.lt;/listenergt; 4.lt;context-paramgt; 5. lt;param-namegt;contextConfigLocationlt;/param-namegt; 6. lt;param-valuegt;classpath: bean. xmllt;/param-valuegt; 7.lt;/context-paramgt;lt;/spangt;当你已经完成上面描述的配置的时候, 还可能出现下面的这个异常, 异常信息如下(这个是浏览器报的异常, 后台没有异常, 服务器启动正常): pl ai n
4、view plaincopy 1.lt;span style=font-size: 24px; gt;Struts Problem Report 2. 3.Struts has detected an unhandled exception:4. 5.Messages: 6.Cannot convert value of type com. sun. proxy. $Proxy8 implementing com. zsq. wxssh. service. UserService, org. springframework. aop. SpringProxy, org. springframe
5、work. aop. framework. Advisedto required type com. zsq. wxssh.serviceimpl. UserServiceImplfor property userServiceImpl :no matching editors or conversion strategy found 7.Failed to convert property value of type com. sun. proxy. $Proxy8 implementing com. zsq. wxssh. service. UserService, org. spring
6、framework. aop. SpringProxy, org. springframework. aop. framework. Advisedto required type com. zsq. wxssh. serviceimpl. UserServiceImplfor property userServiceImpl ;nested exception is java. lang. IllegalArgumentException:Cannot convert value of type com. sun. proxy. $Proxy8 implementing com. zsq.
7、wxssh. service. UserService, org. springframework. aop. SpringProxy, org. springframework. aop. framework. Advisedto required type com. zsq. wxssh. serviceimpl. UserServiceImplfor property userServiceImpl :no matching editors or conversion strategy found 8.Unable to instantiate Action,com. zsq. wxss
8、h. action. LoginAction,defined for Loginin namespace / Failed to convert property value of type com. sun. proxy. $Proxy8 implementing com. zsq. wxssh. service. UserService, org. springframework. aop. SpringProxy, org. springframework. aop. framework. Advisedto required type com. zsq. wxssh. servicei
9、mpl. UserServiceImpl for property userServiceImpl ;nested exception is java. lang. IllegalArgumentException:Cannot convert value of type com. sun. proxy. $Proxy8 implementing com. zsq. wxssh. service. UserService, org. springframework. aop. SpringProxy, org. springframework. aop. framework. Advisedt
10、o required type com. zsq. wxssh. serviceimpl. UserServiceImplfor property userServiceImpl :no matching editors or conversion strategy found 9.File:org/springframework/beans/TypeConverterDelegate. java 10.Line number: 231 11.Stacktraces 12. 13.Unable to instantiate Action,com. zsq. wxssh. action. Log
11、inAction,defined for Loginin namespace / Failed to convert property value of type com. sun. proxy. $Proxy8 implementing com. zsq. wxssh. service. UserService, org. springframework. aop. SpringProxy, org. springframework. aop. framework. Advisedto required type com. zsq. wxssh. serviceimpl. UserServi
12、ceImpl for property userServiceImpl ;nested exception is java. lang. IllegalArgumentException:Cannot convert value of type com. sun. proxy. $Proxy8 implementing com. zsq. wxssh. service. UserService, org. springframework. aop. SpringProxy, org. springframework. aop. framework. Advisedto required typ
13、e com. zsq. wxssh. serviceimpl. UserServiceImplfor property userServiceImpl :no matching editors or conversion strategy found . opensymphony. xwork2. DefaultActionInvocation. createAction(DefaultActionInvocation. java: 316). opensymphony. xwork2. DefaultActionInvocation. init(DefaultActionInvocation
14、. java: 397). opensymphony. xwork2. DefaultActionProxy. prepare(DefaultActionProxy. java: 194)17.org. apache. struts2. impl. StrutsActionProxy. prepare(StrutsActionProxy. java: 63)18.org. apache. struts2. impl. StrutsActionProxyFactory. createActionProxy(StrutsActionProxyFactory. java: 39). opensymp
15、hony. xwork2. DefaultActionProxyFactory. createActionProxy(DefaultActionProxyFactory. java: 58)20.org. apache. struts2. dispatcher. Dispatcher. serviceAction(Dispatcher.java: 553)21.org. apache. struts2. dispatcher. ng. ExecuteOperations. executeAction(ExecuteOperations. java: 77)22.org. apache. str
16、uts2. dispatcher. ng. filter. StrutsPrepareAndExecuteFilter. doFilter(StrutsPrepareAndExecuteFilter. java: 99)23.org. apache. catalina. core. ApplicationFilterChain. internalDoFilter(ApplicationFilterChain. java: 235)24.org. apache. catalina. core. ApplicationFilterChain. doFilter(ApplicationFilterC
17、hain. java: 206)25.org. apache. catalina. core. StandardWrapperValve. invoke(StandardWrapperValve. java: 233)26.org. apache. catalina. core. StandardContextValve. invoke(StandardContextValve. java: 191)27.org. apache. catalina. core. StandardHostValve. invoke(StandardHostValve. java: 127)28.org. apa
18、che. catalina. valves. ErrorReportValve. invoke(ErrorReportValve. java: 103)29.org. apache. catalina. core. StandardEngineValve. invoke(StandardEngineValve. java: 109)30.org. apache. catalina. connector. CoyoteAdapter. service(CoyoteAdapter.java: 293)31.org. apache. coyote. http11. Http11AprProcesso
19、r. process(Http11AprProcessor. java: 879)32.org. apache. coyote. http11. Http11AprProtocol$Http11ConnectionHandler. process(Http11AprProtocol. java: 600)33.org. apache. tomcat. util. net. AprEndpoint$Worker. run(AprEndpoint. java: 1703)34.java. lang. Thread. run(Thread. java: 724)35. 36.org. springf
20、ramework. beans. TypeMismatchException:Failed to convert property value of type com. sun. proxy. $Proxy8 implementing com. zsq. wxssh.service. UserService, org. springframework. aop. SpringProxy, org. springframework. aop. framework. Advisedto required type com. zsq. wxssh. serviceimpl. UserServiceI
21、mplfor property userServiceImpl ;nested exception is java. lang. IllegalArgumentException:Cannot convert value of type com. sun. proxy. $Proxy8 implementing com. zsq. wxssh. service. UserService, org. springframework. aop. SpringProxy, org. springframework. aop. framework. Advisedto required type co
22、m. zsq. wxssh. serviceimpl. UserServiceImplfor property userServiceImpl :no matching editors or conversion strategy found 37.org. springframework. beans. BeanWrapperImpl. convertForProperty(BeanWrapperImpl. java: 391)38.org. springframework. beans. factory. support. AbstractAutowireCapableBeanFactor
23、y. convertForProperty(AbstractAutowireCapableBeanFactory. java:1289)39.org. springframework. beans. factory. support. AbstractAutowireCapableBeanFactory. applyPropertyValues(AbstractAutowireCapableBeanFactory. java: 1250)40.org. springframework. beans. factory. support. AbstractAutowireCapableBeanFa
24、ctory. populateBean(AbstractAutowireCapableBeanFactory. java: 1010)41.org. springframework. beans. factory. support. AbstractAutowireCapableBeanFactory. autowireBeanProperties(AbstractAutowireCapableBeanFactory. java: 329). opensymphony. xwork2. spring. SpringObjectFactory. autoWireBean(SpringObject
25、Factory. java: 203). opensymphony. xwork2. spring. SpringObjectFactory. buildBean(SpringObjectFactory. java: 183). opensymphony. xwork2. spring. SpringObjectFactory. buildBean(SpringObjectFactory. java: 154). opensymphony. xwork2. ObjectFactory. buildBean(ObjectFactory. java: 151). opensymphony. xwo
26、rk2. ObjectFactory. buildAction(ObjectFactory. java: 121). opensymphony. xwork2. DefaultActionInvocation. createAction(DefaultActionInvocation. java: 297). opensymphony. xwork2. DefaultActionInvocation. init(DefaultActionInvocation. java: 397). opensymphony. xwork2. DefaultActionProxy. prepare(Defau
27、ltActionProxy. java: 194)50.org. apache. struts2. impl. StrutsActionProxy. prepare(StrutsActionProxy. java: 63)51.org. apache. struts2. impl. StrutsActionProxyFactory. createActionProxy(StrutsActionProxyFactory. java: 39). opensymphony. xwork2. DefaultActionProxyFactory. createActionProxy(DefaultAct
28、ionProxyFactory. java: 58)53.org. apache. struts2. dispatcher. Dispatcher. serviceAction(Dispatcher.java: 553)54.org. apache. struts2. dispatcher. ng. ExecuteOperations. executeAction(ExecuteOperations. java: 77)55.org. apache. struts2. dispatcher. ng. filter. StrutsPrepareAndExecuteFilter. doFilter
29、(StrutsPrepareAndExecuteFilter. java: 99)56.org. apache. catalina. core. ApplicationFilterChain. internalDoFilter(ApplicationFilterChain. java: 235)57.org. apache. catalina. core. ApplicationFilterChain. doFilter(ApplicationFilterChain. java: 206)58.org. apache. catalina. core. StandardWrapperValve.
30、 invoke(StandardWrapperValve. java: 233)59.org. apache. catalina. core. StandardContextValve. invoke(StandardContextValve. java: 191)60.org. apache. catalina. core. StandardHostValve. invoke(StandardHostValve. java: 127)61.org. apache. catalina. valves. ErrorReportValve. invoke(ErrorReportValve. java: 103)62.org. apache. catalina. core. StandardEngineValve. invoke(StandardEngineValve. java: 109)63.org. apache. catalina. connector. CoyoteAdapter. service(CoyoteAdapter.java: 293)64.org. apache. coyote. http11. Http11AprProcessor. process(Http11AprProcessor. java: 879)65. .