Struts注册Spring Context的三种方式

来源:互联网 发布:吞噬怪物的孩子知乎 编辑:程序博客网 时间:2024/05/16 17:12

(1)使用Struts插件

         在struts-config.xml中
       

  <plug-in className="org.springframework.web.struts.ContextLoaderPlugin">
    
<set-property property="contextConfigLocation"
                  value
="applicationContext.xml"/>
  
</plug-in>

(2)在web.xml中使用Listener

 

<context-param>
  
<param-name>contextConfigLocation</param-name>
        
<param-value>
    /WEB-INF/classes/applicationContextxml,
        
</param-value>
</context-param>
<listener>
          
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>     

 (2)在web.xml中使用Servlet

<servlet-name>springInitServlet</servlet-name>
<servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class>
<load-on-startup>0</load-on-startup>

原创粉丝点击