struts2单独使用时action由struts2自己负责创建;与spring集成时,action实例由spring负责创建(依赖注入)。这导致在两种情况下struts.xml配置文件的略微差异。

假如:LoginAction在包cn.edu.jlu.cs.action中。

1. struts2单独使用时,action的class属性为LoginAction的全路径名,如下:

...

<action name="login" class="cn.edu.jlu.cs.action.LoginAction">

<result name="studentSuccess">

/student/studentindex.jsp

</result>

...

2. struts2与spring集成时,class属性是spring的applicationContext.xml中配置的bean的id属性值。

---------------------------------------------------------------------------------------

//struts.xml

...

<action name="login" class="LoginAction">

<result name="studentSuccess">

/student/studentindex.jsp

</result>

...

----------------------------------------------------------------------------------------

//applicationContext.xml    或者在spring相应的配置文件中

...

<bean id="LoginAction" class="cn.edu.jlu.cs.action.LoginAction" />

struts2与spring集成时action的class属性值意义的更多相关文章

  1. struts2中action的class属性值意义

    整合了spring就不同了,orz struts2单独使用时action由struts2自己负责创建:与spring集成时,action实例由spring负责创建(依赖注入).这导致在两种情况下str ...

  2. struts2与spring集成时,关于class属性及成员bean自动注入的问题

    http://blog.csdn.net/sun_zhicheng/article/details/24232129

  3. struts2与spring整合时需要注意的点

    首先我们需要明白spring整合struts2中的什么东西,spring中的核心就是IOC和AOP,IOC是对象的容器,AOP是处理动态代理的;比如spring与hibernate整合时就要用到aop ...

  4. Struts2和Spring集成

    Spring是一个流行的Web框架,它提供易于集成与很多常见的网络任务.所以,问题是,为什么我们需要Spring,当我们有Struts2?Spring是超过一个MVC框架 - 它提供了许多其它好用的东 ...

  5. Mybatis与Spring集成时都做了什么?

    Mybatis是java开发者非常熟悉的ORM框架,Spring集成Mybatis更是我们的日常开发姿势. 本篇主要讲Mybatis与Spring集成所做的事情,让读过本文的开发者对Mybatis和S ...

  6. Struts2 自定义拦截器时Action无法接收到参数

    问题:自定义拦截器,没有添加defaultStack导致Action无法接受到参数 解决办法: 方法一,添加defaultStack,然后在Action中引用 自定义的stack,其实defaultS ...

  7. Struts2 和 spring mvc的 迭代标签常用属性对比

    <s:iterator value="#users" var="u" status="st"> <c:forEach  i ...

  8. struts框架中OGNL表达式的使用之jsp页面获取action中的属性值

    在jsp页面中获取action中的值: 1.写一个action类OgnlAction类: 需要注意的地方: 如果在aciton中直接使用ognl表达式,将值存储的值栈中,是不能通过跳转将值传到jsp页 ...

  9. js点击标签时获取当前标签属性值

    document.body.onclick=function(){ var obj = document.elementFromPoint(event.clientX,event.clientY); ...

随机推荐

  1. A Tour of Go Arrays

    The type [n]T is an array of n values of type T. The expression var a [10]int declares a variable a  ...

  2. 用java面向对象的思想实现的汉诺塔问题

    package hanoi.com; public class Disc { private String name; private int level; public Disc(){ name = ...

  3. nyoj 456 邮票分你一半

    邮票分你一半 时间限制:1000 ms  |  内存限制:65535 KB 难度:3   描述      小珂最近收集了些邮票,他想把其中的一些给他的好朋友小明.每张邮票上都有分值,他们想把这些邮票分 ...

  4. Android文字的阴影效果

    <!-- android:shadowDx 阴影的水平偏移量 即往右移的距离 --> <!-- android:shadowDy 阴影的垂直偏移量 即往下移的距离--> < ...

  5. js split str.split(&quot; &quot;); split使用方法 在某处截字符串

    <script language="javascript">    str="2,2,3,5,6,6"; //这是一字符串var strs= new ...

  6. java缓存算法【转】

    http://my.oschina.net/u/866190/blog/188712 提到缓存,不得不提就是缓存算法(淘汰算法),常见算法有LRU.LFU和FIFO等算法,每种算法各有各的优势和缺点及 ...

  7. uva340 数字匹配检索问题

    这道题目大意是:给定一个secret code,然后输入guess code,让你编程给出提示,提示的格式是(i,j),其中i表示strong match的个数,j表示weak match的个数.所谓 ...

  8. [Javascript] Drawing Paths - Lines and Rectangles

    <!DOCTYPE html> <html> <head> <meta name="description" content=" ...

  9. [React] React Fundamentals: Add-on ClassSet() for ClassName

    To get the add-ons, use react-with-addons.js (and its minified counterpart) rather than the common r ...

  10. 解决Eclipse自己主动补充问题空间

    假设我们使用增强的战斗有时当代码完成功能 String ss时却发挥String ssString; Integer i 但打了 Integer integer; 很麻烦. 为这包的关系 org.ec ...