论坛首页 入门技术论坛

spring来管理action的3种方法

浏览 3273 次
该帖已经被评为新手帖
作者 正文
   发表时间:2008-03-25  
用spring来管理action的方法,把每个action都注入了applicationContext.xml中
在struts-config.xml中action的type用的是org.springframework.web.struts.DelegatingActionProxy类
交给spring来管理
<controller processorClass="org.springframework.web.struts.DelegatingRequestProcessor" />
第一种:
web.xml
<context-param> 
    <param-name> contextConfigLocation </param-name> 
    <param-value> /WEB-INF/applicationContext.xml </param-value> 
</context-param> 
<servlet-name>SpringContextServlet</servlet-name> 
		<servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class> 
		<load-on-startup>1</load-on-startup> 
	</servlet> 


第二种:
web.xml
<context-param> 
    <param-name> contextConfigLocation </param-name> 
    <param-value> /WEB-INF/applicationContext.xml </param-value> 
</context-param> 

<listener> 
    <listener-class> org.springframework.web.context.ContextLoaderListener </listener-class> 
</listener> 


第三种:
用struts-config.xml的
<plug-in   className= "org.springframework.web.struts.ContextLoaderPlugIn "> 
<set-property   property= "contextConfigLocation "   value= "/WEB-INF/applicationContext.xml "   /> 
</plug-in> 

论坛首页 入门技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics