错误信息:
Caused by: Cannot locate the chosen ObjectFactory implementation: spring - [unknown location]
at org.apache.struts2.config.AbstractBeanSelectionProvider.alias(AbstractBeanSelectionProvider.java:74)
at org.apache.struts2.config.AbstractBeanSelectionProvider.alias(AbstractBeanSelectionProvider.java:45)
at org.apache.struts2.config.DefaultBeanSelectionProvider.register(DefaultBeanSelectionProvider.java:363)
at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reloadContainer(DefaultConfiguration.java:240)
at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:67)
... 18 more
背景:
引入Struts基本必需包:
commons-lang3-3.2.jar
commons-fileupload-1.3.1.jar
commons-io-2.2.jar
freemarker-2.3.22.jar
javassist-3.11.0.GA.jar
ognl-3.0.6.jar
struts2-core-2.3.24.1.jar
xwork-core-2.3.24.1.jar
引入Spring-Web包:
aopalliance-1.0.jar
commons-logging-1.1.1.jar
spring-aop-4.2.4.RELEASE.jar
spring-beans-4.2.4.RELEASE.jar
spring-context-4.2.4.RELEASE.jar
spring-core-4.2.4.RELEASE.jar
spring-expression-4.2.4.RELEASE.jar
spring-web-4.2.4.RELEASE.jar
Struts.xml
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN" "http://struts.apache.org/dtds/struts-2.3.dtd"> <struts> ...... <!-- 指定由spring负责action对象的创建 --> <constant name="struts.objectFactory" value="spring" /> ...... </struts>
这个时候报这个错误原因就是还缺少一个jar包:
struts2-spring-plugin-2.3.15.1.jar 它是整合Struts和Spring的Jar