我使用spring 2.0,hibernate 3.1,struts2.1.6作为项目开发框架-----------------------------------------
struts已导入如下jar包:struts2-core-2.1.6.jarstruts2-spring-plugin-2.1.6.jarxwork-2.1.2.jarognl-2.6.11.jarcommons-logging-api-1.1.jarcommons-fileupload-1.2.1.jarfreeer-2.3.13.jar
------------------------------------------struts.xml配置如下:<struts>
<constant name="struts.objectFactory" value="spring" />
</struts>
-----------------------------------------------------------------web.xml配置如下:         <listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener> <filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
</filter> <filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
-------------------------------------------------------------------------------
tomcat启动报错:[u]Caused by: Cannot locate the chosen ObjectFactory implementation: spring - [unknown location][/u]
at org.apache.struts2.config.BeanSelectionProvider.alias(BeanSelectionProvider.java:287)
at org.apache.struts2.config.BeanSelectionProvider.alias(BeanSelectionProvider.java:258)
at org.apache.struts2.config.BeanSelectionProvider.register(BeanSelectionProvider.java:203)
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:165)
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:55)
... 30 more
---------------------------------------------------------------------------------
注意:就算我把struts2的过滤器配置到spring监听器前也是报同样的错误......
---------------------------------------------------------------------------------
请高手指点下要怎么解决此问题啊...................小弟十分感激!

解决方案 »

  1.   

    可能引起错误原因:没有添加struts2-spring-plugin-XXXX.jar
    但是我把这个包去掉后,然后去掉struts.xml中<constant name="struts.objectFactory" value="spring" />
    也可以。如果你的项目只有一个plugin可以省略
      

  2.   

    在struts.properties中添加:
    struts.objectFactory=com.opensymphony.xwork2.ObjectFactory
    如下即可
      

  3.   

    加了struts2-spring-plugin-XXXX.jar这个包之后,真的没报错了耶!!谢谢啊!!
      

  4.   

    高手如云啊!我加上struts2-spring-plugin-XXXX.jar这个包之后立马就好了,真实感谢啊
      

  5.   

    struts2-spring-plugin-***.jar
    xwork-*.jar
    struts2-core-*.jar
    ognl-*.jar
    freeer-*.jar以上是 Struts2 5个必须的 Jarcommons-fileupload-*.jar   文件上传用到
    commons-io-*.jar         IO流用到切记啊!
      

  6.   

    我加了struts2-spring-plugin-XXXX.jar包,但还是报这个错误啊。