从struts.xml文件通过代理要跳到spring配置文件applicationContext.xml里面,但是在发布启动Tomcat时报错,代码好像没的什么错,不知道是不是哪没配置或是jar包问题。帮忙解决一下,在线等
struts.xml文件
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">
 <struts>
       <constant name="struts.objectFactory" value="spring" ></constant>  
     <package name="crm_Personnel" extends="struts-default">
     
      <action name="logins" class="loginSpring">
          <result name="success">/success.jsp</result>
          <result name="error">/error.jsp</result>
      </action>
     </package>
 </struts>
web.xml文件
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4" 
xmlns="http://java.sun.com/xml/ns/j2ee" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
   <context-param>
   <param-name>contextConfigLocation</param-name>
   <param-value>/WEB-INF/applicationContext.xml</param-value>
  </context-param>

<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>

  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list>
</web-app>

解决方案 »

  1.   

    忘了把错误给贴出来。
    严重: Exception starting filter struts2
    Cannot locate the chosen ObjectFactory implementation: spring - [unknown location]
    at org.apache.struts2.config.BeanSelectionProvider.alias(BeanSelectionProvider.java:224)
    at org.apache.struts2.config.BeanSelectionProvider.alias(BeanSelectionProvider.java:195)
    at org.apache.struts2.config.BeanSelectionProvider.register(BeanSelectionProvider.java:153)
    at com.opensymphony.xwork2.config.impl.DefaultConfiguration.reload(DefaultConfiguration.java:131)
    at com.opensymphony.xwork2.config.ConfigurationManager.getConfiguration(ConfigurationManager.java:52)
    at org.apache.struts2.dispatcher.Dispatcher.init_PreloadConfiguration(Dispatcher.java:395)
    at org.apache.struts2.dispatcher.Dispatcher.init(Dispatcher.java:452)
    at org.apache.struts2.dispatcher.FilterDispatcher.init(FilterDispatcher.java:201)
    at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:275)
      

  2.   

    <context-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>/WEB-INF/applicationContext.xml</param-value>
      </context-param>只配置了spring的参数  没有配置spring的监听
      

  3.   

    <listener>
    <listener-class>
    org.springframework.web.context.ContextLoaderListener
    </listener-class>
    </listener>
      

  4.   

    配置上spring的监听就可以了
    <listener>
    <listener-class>
    org.springframework.web.context.ContextLoaderListener
    </listener-class>
    </listener>
      

  5.   

    好像有很多的错误啊
    struts.xml文件中package没有namespace
    wem。xml文件中应该是这样配置的
    <?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
    http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <!-- 定义spring配置文件在哪里 -->
    <context-param>
    <!-- 参数名称必须叫contextConfigLocation -->
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath*:applicationContext-*.xml</param-value>
    </context-param>
    <listener>
    <!-- 在应用服务器启动的时候,根据contextConfigLocation的取值,
    创建BeanFactory对象,并且把这个对象放入ServletContext -->
    <listener-class>
    org.springframework.web.context.ContextLoaderListener
    </listener-class>
    </listener> <filter>
    <filter-name>openSessionInViewFilter</filter-name>
    <filter-class>
    org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
    </filter-class>
    </filter> <filter-mapping>
    <filter-name>openSessionInViewFilter</filter-name>
    <url-pattern>/*</url-pattern>
    </filter-mapping> <filter>
    <filter-name>struts2</filter-name>
    <filter-class>
    org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
    </filter-class>
    </filter> <filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>/*</url-pattern>
    </filter-mapping> <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
    </welcome-file-list>
    </web-app>
      

  6.   

    要在web.xml配置spring listener