日期:2014-05-20  浏览次数:20755 次

Struts Spring整合问题
Struts1.2+Spring2.0的整合问题
Struts中的struts-config.xml: 
 <action-mappings>
  <action path="/index" forward="/index.jsp"></action>
  <action
  attribute="userForm"
  name="userForm"
  path="/register"
  scope="request"
  type="org.springframework.web.struts.DelegatingActionProxy">
  <forward name="success" path="/success.jsp"></forward>
  </action>
  </action-mappings>
  <message-resources parameter="com.ApplicationResources" />
  <plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation" value="/WEB-INF/classes/applicationContext.xml" />
</plug-in>
</struts-config>
Spring applicationContext.xml:
  <bean name="/register" class="com.RegisterAction">
  <property name="dao" ref="membersDao"></property>
  </bean>
用的是Tomcat5.5 J2EE1.4
现在碰到的问题就是启动tomcat以后貌似无法解析.do文件 提示HTTP Status 404 - Servlet action is not available
.jsp能正常执行
如果在工程中使用Struts1.2,再在web.xml中使用listener载入spring,不整合它们两个,也还是不行
web.xml:
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
............
</servlet-mapping>
如果不使用Struts只在web.xml中配置Spring
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
这样Spring在Servlet中用着没什么问题
网上找了半天说是Spring2.0与Struts1.2整合不解析什么xml文件?只能用Spring1.2么?偶没学过Struts2

------解决方案--------------------
配制一下.REQUESTPROCESSOR
------解决方案--------------------
以上大部分配置都copy自楼主

在web.xml中楼主要加上
<context-param>
<param-name>contextConfigLocation </param-name>
<param-value>/WEB-INF/classes/applicationContext.xml </param-value>
</context-param> 

才能指定到classpath路径中