spring 整合struts
1.例子:未被spring整合
struts.xml 的配置文件
<constant name="struts.enable.DynamicMethodInvocation" value="true" />
<constant name="struts.configuration.xml.reload" value="true"/>
<!--配置扩展名 .do-->
<constant name="struts.action.extension" value="do"></constant> <package name="default" namespace="/" extends="struts-default">
<!-- {1} 代表第一个* {2} 代表第二个* -->
<action name="*_*" class="com.test.controller.{1}Action" method="{2}">
<result name="success">index.jsp</result>
</action>
</package>

注意这个配置,全类名。 struts 通过actionMaping 的配置找到这个类
测试:调用com.test.controller 包下的StudentAction 这个类的doGetStudentInfo()方法
前台调用这个action的方式 就是

注意:这里是Student首字母大写,是StudentAction 的前半部分
2. 例子:spring整合之后
struts.xml 的配置文件
<struts>
<!--由spring 取代struts 创建对象的实例 -->
<constant name="struts.objectFactory" value="spring" />
<!--配置spring自动装配实例-->
<constant name="struts.objectFactory.spring.autoWire" value="true"></constant>
<constant name="struts.enable.DynamicMethodInvocation" value="true" />
<constant name="struts.configuration.xml.reload" value="true"/>
<!--配置扩展名 .do-->
<constant name="struts.action.extension" value="do"></constant> <package name="default" namespace="/" extends="struts-default"> <action name="*_*" class="{1}Action" method="{2}">
<result name="success">index.jsp</result>
</action>
</package> <!-- <include file="example.xml"/> --> </struts>

注意这个地方:已经变成了spring 自动创建的beanid,这里自动创建的beanid 是通过注解生成的

这个注解生成的beanid 是studentAction ,注意这里的首字母是小写,这是spring创建实例的时候转化的。
测试:前台进行访问

报错:原因,时候应为这时候要调用的action 实例名已经是studenAction 而不是StudentAction

正确。
此时spring配置文件不用特别的设置配置,已经将spring 和 struts 整合完毕
spring 整合struts的更多相关文章
- SSH开发实践part4:Spring整合Struts
1 好了,前面spring与hibernate的整合开发我们基本上讲完了,现在要开始服务层的开发,也就是处理事务的action,在这里我们需要引入spring与struts的整合.也就是将action ...
- Spring整合Struts的两种方式介绍
1 使用Spring托管Struts Action 该种方式就是将Struts Action也视为一种Bean交给Spring来进行托管,使用时Struts的配置文件中配置的Action的classs ...
- 8 -- 深入使用Spring -- 7... Spring 整合 Struts 2
8.7 Spring 整合 Struts2 8.7.1 启动Spring 容器 8.7.2 MVC框架与Spring整合的思考 8.7.3 让Spring管理控制器 8.7.4 使用自动装配
- spring整合struts
整合目标:使用spring的bean管理struts action service. 整合步骤: 一.加入spring 1.加入spring jar包 2.配置web.xml文件 <contex ...
- Spring整合struts的配置文件存放问题
只使用Spring的时候,我把applicationContext.xml是放在项目的src路径下的,这样使用ClassPathXmlApplicationContext很方便嘛 整合了struts之 ...
- spring 整合 struts
struts配置 objectFactory 在struts.xml添加,用spring工厂管理action对象 <constant name="struts.objectFactor ...
- 【SSH】Spring 整合 Struts
添加 spring-struts-3.2.9.RELEASE.jar struts-config.xml 添加 <controller> <set-property property ...
- Spring入门(四)— 整合Struts和Hibernate
一.Spring整合Struts 1. 初步整合 只要在项目里面体现spring和 strut即可,不做任何的优化. struts 环境搭建 创建action public class UserAct ...
- Spring整合Struts2框架的第二种方式(Action由Spring框架来创建)(推荐大家来使用的)
1. spring整合struts的基本操作见我的博文:https://www.cnblogs.com/wyhluckdog/p/10140588.html,这里面将spring与struts2框架整 ...
随机推荐
- 反混淆、反编译unity3d动画插件DFTweenLite得到源代码
出处:http://blog.csdn.net/u010019717 author:孙广东 时间:2015.3.17 23:00 我为什么要得到这个源代码.由于有洁癖! 对于Itween ...
- 返回零长度的数组或者集合,而不是null
<<Effective Java>> 第四十三条:返回零长度的数组或者集合,而不是null 假设一个方法的返回值类型是集合或者数组 .假设在方法内部须要返回的集合或者数组是零长 ...
- 树莓派 mongodb 安装&报错处理
树莓派 mongodb 安装&报错处理 编译过的源码下载地址: http://files.cnblogs.com/files/xueshanshan/mongodb-rpi.zip addus ...
- OpenCV2马拉松第13圈——模版匹配
收入囊中 在http://blog.csdn.net/abcd1992719g/article/details/25505315这里,我们已经学习了怎样利用反向投影和meanshift算法来在图像中查 ...
- mysql连接com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link
jdbc驱动:mysql-connector-java-5.1.39-bin.jar 这个有问题, 换成:mysql-connector-java-5.1.34.jar 就可以了
- touch all contents in a folder recursively
https://superuser.com/questions/598163/powershell-touch-all-files-newer-than Powershell to use Unix ...
- javascript来实现详细时间提醒信息效果
我们经常在社交网络上面看到很人性化的时间提示比如,你的朋友几分钟前更新了什么,你的朋友几天前更新了什么信息. 这些小tips比直接显示某年某月人性化很多.我们可以用不同的程序实现这种效果.中国音效网下 ...
- 深入探析c# Socket
最近浏览了几篇有关Socket发送消息的文章,发现大家对Socket Send方法理解有所偏差,现将自己在开发过程中对Socket的领悟写出来,以供大家参考. (一)架构 基于TCP协议的Socket ...
- luogu 3804 【模板】后缀自动机
学习一波后缀自动机 求字符串$S$的所有出现次数不为1的子串的出现次数乘上该子串长度的最大值 #include<iostream> #include<cstdio> #incl ...
- String 对象
1 你使用位置(索引)可以访问字符串中任何的字符: var str="this is a demo"; alert(str[3])// s 字符串的索引从零开始, 所以字符串 ...