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框架整 ...
随机推荐
- Receiver type ‘X’ for instance message is a forward declaration
这往往是引用的问题. ARC要求完整的前向引用,也就是说在MRC时代可能仅仅须要在.h中申明@class就能够,可是在ARC中假设调用某个子类中未覆盖的父类中的方法的话.必须对父类.h引用,否则无法编 ...
- 訪问的网页自己主动打开QQ对话
今天訪问中国论文网,自己主动就弹出与QQ的对话框,非常是好奇.于是查看网页源码发现例如以下可疑处: <script type="text/javascript"> fu ...
- NHibernate直接执行SQL进行插入
有时候,需要用NHibernate直接执行SQL进行数据insert或update. 怎么写呢?简单一点的,可以直接拼凑出来的SQL,这样写: using NHibernate; StringBuil ...
- javascript闭包的应用
我印象中,javascript的闭包属于进阶的范畴,无非是用来在面试中装装逼而已.你看我身边的一个小伙子,有一天我装逼地问他什么是javascript的闭包,他居然连听都没听说过.但他做起前端的东西来 ...
- 生成器 减少代码行数 map reduce
map reduce l = [[2, 3], [2, 3, 4]] ll = [2, 3, 4] l = [int(i) for i in set(','.join([','.join([str(i ...
- 65*24=1560<2175 对数据的统计支撑决策假设 历史数据正确的情况下,去安排今后的任务
没有达到目标,原因不是时间投入不够,而是不用数据决策,不用数据调度定时脚本 [数据源情况统计]----># 近30天,日生效coin数目SELECT COUNT(DISTINCT coin) A ...
- 以太坊源码学习 – EVM
学习文档链接:here 一.虚拟机外 主要功能: 执行前将Transaction类型转化成Message,创建虚拟机(EVM)对象,计算一些Gas消耗,以及执行交易完毕后创建收据(Receipt)对象 ...
- jsp实现翻页功能
jsp实现翻页功能 要实现翻页功能,只需要设置一个pageIndex即可,然后每次加载页面时通过pageIndex去加载数据就行. 那么我们可以设置一个隐藏的input框,用于传递pageIndex给 ...
- C语言-1.结构体,2.枚举,3.typedef,4.预处理指令的概念,5.条件编译
1. 结构体数组 定义:由若干个相同类型的结构体变量组成的有序的集合. 定义格式: 1) 定义结构体的同时定义结构体数组 struct Car{ int lunzi; int speed; }cars ...
- Linux网络协议栈(二)——套接字缓存(socket buffer)
Linux网络核心数据结构是套接字缓存(socket buffer),简称skb.它代表一个要发送或处理的报文,并贯穿于整个协议栈.1. 套接字缓存skb由两部分组成:(1) 报文数据:它 ...