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. Evaluate Reverse Polish Notation --leetcode

    原题链接:https://oj.leetcode.com/problems/evaluate-reverse-polish-notation/ 题目大意:给出逆波兰式,然后求其结果. 解题方法:单个栈 ...

  2. mongodb05---游标

    游标cursor: 通俗的说,游标不是查询结果,而是查询的返回资源,或者接口. 通过这个接口,你可以逐条读取.就像php中的fopen打开文件,得到一个资源一样, 通过资源,可以一行一行的读文件. v ...

  3. 基于TCP的字符串传输程序

    ---恢复内容开始--- LINUX中的网络编程是通过SOCKET接口来进行的. Socket(套接字) Socket相当于进行网络通信两端的插座,只要对方的Socket和自己的Socket有通信联接 ...

  4. DOM方式解析xml实例2

    老样子,javabean实体类: import java.io.*; public class Book implements Serializable { private int id; priva ...

  5. Linux网络协议栈(四)——链路层(1)

    1.接收帧当网络适配器接收到数据帧时,就会触发一个中断,中断处理程序执行一些需要及时处理的任务,然后在下半部进行其它可以延迟的处理.中断处理程序主要进行以下一些操作:(1)    分配sk_buff数 ...

  6. bzoj1090 [SCOI2003]字符串折叠——区间DP

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=1090 区间DP... 代码如下: #include<iostream> #inc ...

  7. appium学习【一】:pycharm运行不生成HtmlTestRunner测试报告

    参考文章和解决办法:http://blog.csdn.net/xie_0723/article/details/50825310                  http://jingyan.bai ...

  8. 【算法小总结】LCS问题&&HDU1243

    LCS问题,又称最长公共子序列问题,是DP中较简单的一种,今天我们就来简单讲解一下. 设s1:AEGLEGLLELGEL 设s2:LREGELGEGLEG 求两个字符串的最大公共子序列长度 输出:8 ...

  9. Linux 常用命令十一 ps

    一.ps命令 Linux中的ps命令是Process Status的缩写. ps命令用来列出系统中当前运行的那些进程.ps命令列出的是当前那些进程的快照,就是执行ps命令的那个时刻的那些进程,如果想要 ...

  10. bzoj 4898: [Apio2017]商旅【Floyd+分数规划+二分】

    其实并不会分数规划 因为要最大化 ans=总收益/总路程 ,所以考虑二分答案,找到一条 ans<=总收益/总路程 的回路.先预处理出d(i,j)为(i,j)最短路,w(i,j)为在i买某个物品在 ...