spring2.5 管理sturts2 action问题

编码小兵 发布于 2011/07/29 17:31
阅读 1K+
收藏 0

华为云11月刊推送:DIY微信问答机器人,高性能计算代码的20个技巧!>>>

今天小弟着实悲剧了很长时间 麻烦各位兄台抽空看下

网速有问题 就直接贴了

struts配置文件

<struts>
     <include file="struts-default.xml" />
     <constant name="struts.objectFactory" value="spring" />
     <constant name="struts.i18n.encoding" value="UTF-8" />
     <constant name="struts.custom.i18n.resources" value="message" />
     <include file="struts/struts-index.xml"></include>
</struts>

struts-index.xml配置文件

<struts>
 <package name="index" extends="struts-default" namespace="/index">
  <action name="indexAction" class="indexAction">
   <result name="success">/index.jsp</result>   
  </action>
 </package>
</struts>

spring部分配置文件

<aop:config proxy-target-class="true">
  <aop:pointcut id="goMarryAop"
   expression="execution(* com.gomarry.*.model.service.*.*(..))" />
  <aop:advisor advice-ref="goMarryAdvice" pointcut-ref="goMarryAop" />
 </aop:config>

web.xml配置 部分

  <context-param>
  <param-name>contextConfigLocation</param-name>
  <param-value>classes/spring/applicationContext.xml</param-value>
 </context-param>
 <listener>
  <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
 </listener>
 <listener>
  <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
 </listener>

 

问题就是 我想让spring管理action,当我在struts-index.xml中class属性改为 com.*.*之类的路径 一切正常, 引用了spring中的indexAction就会出现错误,所以spring配置注入那 没有贴出来,

错误是

javax.servlet.ServletException: Unable to instantiate Action, indexAction,  defined for 'index' in namespace '/index'Error creating bean with name 'indexAction' defined in ServletContext resource [/classes/spring/applicationContext-index.xml]: Error setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.TypeMismatchException: Failed to convert property value of type [com.gomarry.index.model.dao.IndexDao] to required type [com.gomarry.index.model.service.IndexService] for property 'indexService'; nested exception is java.lang.IllegalArgumentException: Cannot convert value of type [com.gomarry.index.model.dao.IndexDao] to required type [com.gomarry.index.model.service.IndexService] for property 'indexService': no matching editors or conversion strategy found - action - file:/D:/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/GoMarry/WEB-INF/classes/struts/struts-index.xml:7:44

struts-index.xml:7:44 正是 应用spring中的indexAction

麻烦各位读到这里了, 3Q,呵呵

加载中
返回顶部
顶部