zoukankan      html  css  js  c++  java
  • struts2 委托spring代理action .

    让spring代替struts2生成Action

     

    struts2中提供了一个与spring进行集成的包,位于struts2 的lib下,叫做struts2-spring-plugin.jar。复制到当前目录的WEB-INF/lib下,然后配置struts.xml和applicationContext.xml
     

    (1)在struts.xml的<action>配置中使用class属性指向Spring的<bean>元素:


        <action name="login" class="loginAction" >
             <result name="success">/success.jsp</result>
        </action>


      (2)在applicationContext.xml中配置与<action>的class对应的<bean>元素:


       <bean id="loginAction" class="com.ss.usermgr.actions.LoginAction" scope="prototype">
          <property name="userManager" ref="userManager"/>
       </bean>
     
     在web.xml中添加如下代码:
       <context-param>
          <param-name>contextConfigLocation</param-name>

     

          <!-- 我的applicationContext.xml放在src目录下,所以用classpath*: -->
          <param-value>classpath*:applicationContext-*.xml</param-value>
       </context-param>
     
      <listener>
          <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
      </listener>

    原文:http://blog.csdn.net/youyouzhishen/article/details/5083179

  • 相关阅读:
    Collections和Arrays常用方法
    集合(三)------双列集合
    集合(二)------单列集合
    集合(一)----------概述
    泛型
    线程
    Math类和Random类(数学公式相关类)
    时间相关的类
    Runtime类及其常用方法
    第65题:有效数字
  • 原文地址:https://www.cnblogs.com/hpuCode/p/2625995.html
Copyright © 2011-2022 走看看