zoukankan      html  css  js  c++  java
  • struts2与spring集成时action的class属性值意义

    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" />

  • 相关阅读:
    洛谷 P1692 部落卫队
    洛谷 P1113 杂务
    洛谷 P1546 最短网络 Agri-Net
    洛谷 P2121 拆地毯
    洛谷 P2728 纺车的轮子 Spinning Wheels
    洛谷 P2126 Mzc家中的男家丁
    线段树双标记——乘法和加法
    A. Feed the cat
    洛谷 P1535 游荡的奶牛
    BZOJ1050 [HAOI2006]旅行
  • 原文地址:https://www.cnblogs.com/fanziyang/p/6106694.html
Copyright © 2011-2022 走看看