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框架整 ...
随机推荐
- Oracle11g表空间导入dmp数据
如果你的表数据没有附带表空间和用户名,那么只要一句话 Imp {u_name}/{u_pwd}@{local_svrname} fromuser={from_user} touser={u_name} ...
- 【iOS系列】- UITableView的使用技巧
[iOS系列]- UITableView的使用 UITableView的常用属性 indexpath.row:行 indexpath.section:组 separatorColor:分割线的颜色 s ...
- win7 32位下安装MySQL出现的---1067系统错误---问题及解决
每次安装数据库,总是出现这样那样的问题.如今记录下来,供日后參考咯.... 下载的是解压缩-zip版本号的.安装配置教程參照洪哥笔记文章-<MySQL-5.6.13解压版(zip版)安装配置教程 ...
- eclispe pydev tab改回 空格找到方法了,这个链接:http://stackoverflow.com/questions/23570925/eclipse-indents-new-line-with-tabs-instead-of-spaces
看这个链接: 3down votefavorite 1 I've followed all the suggestions here. When I press return, I get a new ...
- yummain.py install yum 不能运行的原因 yummain.py not found
[root@akinlau ~] wget http://tel.mirrors.163.com/centos/6/os/x86_64/Packages/python-urlgrabber-3.9.1 ...
- POJ1458 Common Subsequence —— DP 最长公共子序列(LCS)
题目链接:http://poj.org/problem?id=1458 Common Subsequence Time Limit: 1000MS Memory Limit: 10000K Tot ...
- BZOJ2761:不重复数字(splay效率对比)
给出N个数,要求把其中重复的去掉,只保留第一次出现的数. 例如,给出的数为1 2 18 3 3 19 2 3 6 5 4,其中2和3有重复,去除后的结果为1 2 18 3 19 6 5 4. In ...
- Memcache存储大数据的问题(大于1m)
Memcached存储单个item最大数据是在1MB内,如果数据超过1M,存取set和get是都是返回false,而且引起性能的问题. 我们之前对排行榜的数据进行缓存,由于排行榜在我们所有sql se ...
- cmath函数整理
double a= pow(double x, double y)://返回x的y次方. double a= sqrt(double x)://返回x的平方根. double a=ceil(doubl ...
- Java-Runoob-高级教程-实例-字符串:08. Java 实例 - 字符串分割(StringTokenizer)
ylbtech-Java-Runoob-高级教程-实例-字符串:08. Java 实例 - 字符串分割(StringTokenizer) 1.返回顶部 1. Java 实例 - 字符串分隔(Strin ...