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的更多相关文章

  1. SSH开发实践part4:Spring整合Struts

    1 好了,前面spring与hibernate的整合开发我们基本上讲完了,现在要开始服务层的开发,也就是处理事务的action,在这里我们需要引入spring与struts的整合.也就是将action ...

  2. Spring整合Struts的两种方式介绍

    1 使用Spring托管Struts Action 该种方式就是将Struts Action也视为一种Bean交给Spring来进行托管,使用时Struts的配置文件中配置的Action的classs ...

  3. 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 使用自动装配

  4. spring整合struts

    整合目标:使用spring的bean管理struts action service. 整合步骤: 一.加入spring 1.加入spring jar包 2.配置web.xml文件 <contex ...

  5. Spring整合struts的配置文件存放问题

    只使用Spring的时候,我把applicationContext.xml是放在项目的src路径下的,这样使用ClassPathXmlApplicationContext很方便嘛 整合了struts之 ...

  6. spring 整合 struts

    struts配置 objectFactory 在struts.xml添加,用spring工厂管理action对象 <constant name="struts.objectFactor ...

  7. 【SSH】Spring 整合 Struts

    添加 spring-struts-3.2.9.RELEASE.jar struts-config.xml 添加 <controller> <set-property property ...

  8. Spring入门(四)— 整合Struts和Hibernate

    一.Spring整合Struts 1. 初步整合 只要在项目里面体现spring和 strut即可,不做任何的优化. struts 环境搭建 创建action public class UserAct ...

  9. Spring整合Struts2框架的第二种方式(Action由Spring框架来创建)(推荐大家来使用的)

    1. spring整合struts的基本操作见我的博文:https://www.cnblogs.com/wyhluckdog/p/10140588.html,这里面将spring与struts2框架整 ...

随机推荐

  1. 关于 iOS 的 StoryBoard,接受的那一刻才发现她的美 - 当然美的事物都须要业心照料

    关于 iOS 的 StoryBoard,接受的那一刻才发现她的美 - 当然美的事物都须要业心照料 太阳火神的漂亮人生 (http://blog.csdn.net/opengl_es) 本文遵循&quo ...

  2. Android之键盘监听的执行机理【看清键盘监听的本质】【入门版】

    以EditText为例: 1.Activity本身也有按键监听 editText按键监听与Activity按键监听关系: Activity本身也有按键监听 并且分按下和松开两个事件监听 editTex ...

  3. [IT学习]GIT 学习

    最近开始了解GIT.有一些不错的资源记录在下面: 1.GIT for teams A book about teams cooperation. 2.GIT https://learngitbranc ...

  4. C项目实践--网络协议和套接字编程

    1.TCP/IP协议 TCP/IP协议是一组包括TCP协议和IP协议,UDP(User Datagram Protocol)协议,ICMP(Internet Control Message Proto ...

  5. Oracle 表的创建 及相关參数

    1. 创建表完整语法 CREATE TABLE [schema.]table (column datatype [, column datatype] - ) [TABLESPACE tablespa ...

  6. PR 修改保存的增强 ME_UPDATE_REQUISITION

    FUNCTION me_update_requisition."""""""""""&qu ...

  7. 比特币交易(Transaction)的输入与输出

    比特币通过“挖矿”机制保证了不能任意造币.通过分布式网络和HashCash机制解决双重支付问题.事实上比特币系统中不存在独立的电子货币,而只存在交易单(账单),货币值是依附于交易单存在的,所以比特币中 ...

  8. android编程取消标题栏方法(appcompat_v7、Theme.NoTitleBar)

    方式一:编码方式 @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstance ...

  9. 连接mysql时报:message from server: "Host '192.168.76.89' is not allowed to connect to this MySQL server

    处理方案: 1.先用localhost方式连接到MySQL数据库,然后使用MySQL自带的数据库mysql; use mysql: 2.执行:select host from user where u ...

  10. [Usaco2015DEC] Breed Counting

    [题目链接] https://www.lydsy.com/JudgeOnline/problem.php?id=4397 [算法] 树状数组 时间复杂度 : O(QlogN) [代码] #includ ...