标题:我的spring和struts怎么总是整合不对呢?我都整了好几天了!!!
取消只看楼主
bjgs2004
Rank: 1
等 级:新手上路
帖 子:33
专家分:0
注 册:2007-3-18
 问题点数:0 回复次数:0 
我的spring和struts怎么总是整合不对呢?我都整了好几天了!!!
我的spring和struts怎么总是整合不对呢?我都弄了好几天了,我都快疯了!!!
只运行struts是正确的,但是一加入spring就出错了!
现象是:运行时候提示:Servlet action is not available
我配置了这两个文件,各位看一看我配的对不对,还要配置其他的文件吗?
1、我的struts-config(在WEB-INF目录下)的主体如下

<struts-config>
<data-sources />
<form-beans>
<form-bean
name="myForm"
type="com.action.myForm">
</form-bean>
</form-beans>
<global-exceptions />
<global-forwards />
<action-mappings>
<action path="/myAction"
type="org.springframework.web.struts.DelegatingActionProxy"
scope="request"
input="index.html"
name="myForm">
<forward name="success" path="/success.jsp"/>
</action>
</action-mappings>
<message-resources parameter="com.yourcompany.struts.ApplicationResources" />
<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation" value="/WEB-INF/applicationContext.xml" />
</plug-in>
</struts-config>

2、applicationContext.xml(在WEB-INF目录下)的主体如下

<bean name="/myAction"
class="com.action.myAction"/>

3、在jsp的form的action:action="myAction.do"
4、web.xml内容如下:
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="2.4" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>3</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>3</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
</web-app>

[此贴子已经被作者于2007-4-19 17:09:36编辑过]

搜索更多相关主题的帖子: spring struts action myForm 
2007-04-18 21:37



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-132988-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.716213 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved