struts1和spring的整合
来源:互联网 发布:风火轮软件 编辑:程序博客网 时间:2024/05/16 11:15
1.先要在struts中配置 将spring的配置文件加载进actionservlet总控中以便等会进行使用 这样可以避免在web.xml下进行配置
<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation" value="/WEB-INF/applicationContext.xml"/></plug-in>
2.然后有三种方式,一种是继承actionsupport,另一种是使用DelegatingRequestProcessor进行配置,
最后一种是使用DelegatingAcionProxy,官方推荐最后一种
3.我们倾向于最后一种实现模式然后开始编写actionform,action
4.在编写完毕之后,我们进行struts配置文件 struts-config.xml的编写
5.首先编写actionform,样例如下
<form-beans ><form-bean name="UserForm" type="com.stu.web.form.UserForm"></form-bean>
</form-beans>
6.然后我们编写action,跟普通action略有不同,有几点需要注意<action path="/login"
<!--type,因为我们使用的是第三种实现模式,所以我们将type定为DelegatingActionProxy-->
type="org.springframework.web.struts.DelegatingActionProxy"
name="UserForm">
<forward name="success" path="/success.jsp"></forward>
</action>
<!--我们还要记住path,因为一会还要用到这个路径-->
这样一个最简单的action就算配置完毕了
7.现在我们转向spring的配置
<bean name="/login" class="com.stu.web.action.LoginAction"></bean>
在这里的name因为bean的id不支持"/",所以我们使用name来进行配置
在这里要跟上面struts的配置进行对比,
spring中的name="/login" struts中的path="/login"
两个相同是因为我们要用spring中的LoginAction定义,来取代struts的管理,
然后使用DelegatingActionProxy来对struts的action进行代理
8.最后我们写好输入和输出的jsp即可
参考:http://blog.csdn.net/caoyinghui1986/article/details/2501914
- Struts1和Spring的整合
- struts1和spring的整合
- Struts1和Spring的整合
- Struts1和Spring整合的步骤
- struts1.x和spring整合
- Hibernate+spring+struts1的整合
- struts1.2和spring的整合几种方式
- 【转】Spring 和 struts1.2 整合的三种方式
- Spring 和 struts1.2 整合的三种方式
- Spring 和struts1 整合的三种方式
- Spring 和 struts1.2 整合的三种方式
- struts1和struts2的整合
- 【原创】Spring、Hibernate、Struts1整合的方式
- Struts1.整合Spring的三种方法
- Struts1.整合Spring的三种方法
- Spring与Struts1的整合方式
- spring整合struts1.3的问题
- struts1.x+spring+hibernate的整合
- 在 MySQL Workbench 中如何可视的建立 MySQL 物理数据模型,并使用它来创建一个 MySQL 数据库
- 关于富文本编辑内容存储到数据库在移动端显示的问题
- 从MVC和三层架构说到ssh整合开发(下)
- 第五章 信用评分模型的开发流程
- notepad++设置用空格取代tab键及修改背景主题
- struts1和spring的整合
- 434. Number of Segments in a String
- svg 透视
- 类和对象的关系
- Python--matplotlib绘图可视化知识点整理
- jqery easyui 给角色分配菜单 利用tree来实现
- 这些警告如何消除
- OpenCV249和VS2010配置
- 网易2017实习生笔试编程题-魔力手环