日期:2014-05-17  浏览次数:20801 次

Cannot locate the chosen ObjectFactory implementation
将action交给spring管理时,我在sturts.xml中加了<constant name="struts.objectFactory" value="spring"/>,且lib目录下也加了struts2-spring-plugin-2.1.8.1.jar。但还是报Cannot locate the chosen ObjectFactory implementation错。
这是怎么回事?
以下是我的sturts.xml:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts PUBLIC
  "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN" "dtds/struts-2.1.7.dtd">

<struts>
<include file="struts-default.xml" />

<constant name="struts.configuration.xml.reload" value="true" />
<constant name="struts.action.extension" value="action" />
<constant name="struts.objectFactory" value="spring"/>
<constant name="struts.custom.i18n.resources" value="applicationResources" />
<constant name="struts.i18n.encoding" value="UTF-8" />
<constant name="struts.locale" value="zh_CN" /> <!-- en_US -->
<constant name="struts.devMode" value="true" /> <!-- true:表明处于开发状态,如果出错,会有详细的错误明细 -->
<constant name="struts.multipart.maxSize" value="1000000000" />

<package name="supply" extends="struts-default" namespace="/supply">
<action name="login" class="com.luckcart.suppliers.action.SuppliersLoginAction" method="login">
<result name="success" type="freemarker">/WEB-INF/template/suppliers/login/login.ftl</result>
</action>
</package>

<!--<include file="struts/struts-suppliers.xml"></include>

--></struts>


------解决方案--------------------
web.xml添加ContextLoaderListener没有。
------解决方案--------------------
一般不用写吧 好像默认值就是 spring