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 Slicing slices

    ---恢复内容开始--- Slices can be re-sliced, creating a new slice value that points to the same array. The ...

  2. error C2589: “(”: “::”右边的非法标记 error C2059: 语法错误 : “::

    1. 错误输出 ./zlibrary/ui/src/win32/w32widgets/W32VBorderBox.cpp(114) : error C2589: “(”: “::”右边的非法标记    ...

  3. 【Apache开源软件基金会项目】

    因为想要继续巩固一下外语,并且扩展下java的知识面,翻译一下Apache软件基金会的各个项目是个不错的选择. 2014-10-19 1 [Apache .NET Ant Libary] .net A ...

  4. springmvc + spring + mybatis + maven整合配置文件

    源码下载地址:http://download.csdn.net/detail/a757956132/9353345 src/main/java sy controller dao model serv ...

  5. PowerShell优化和性能测试

    measure-command -expression {$null = "abc"}  效率高于 {"abc" |out-null } foreach {$p ...

  6. 【转】oracle创建表空间

    原文:http://www.cnblogs.com/netsql/articles/1745978.html 注意点: 1.如果在PL/SQL 等工具里打开的话,直接修改下面的代码中[斜体加粗部分]执 ...

  7. android113 自定义进度条

    MainActivity: package com.itheima.monitor; import android.os.Bundle; import android.app.Activity; im ...

  8. java21 封装Response:

    封装Response: /** * 封装响应信息 */ public class Response { //两个常量 public static final String CRLF="\r\ ...

  9. Cookie中用户登录信息登录验证

    public class FormServlet extends HttpServlet { public void doGet(HttpServletRequest request, HttpSer ...

  10. Oracle错误代码案例总结及解决方案

    引自:http://blog.sina.com.cn/s/blog_9daa54ec0100yr7v.html 常见错误: ORA-00001:违反唯一约束条件(主键错误) ORA-00028:无法连 ...