---
title: "spring struts整合策略"
author: "lemo"
date: "2013-03-22T23:23:23Z"
tags: []
categories: ["编程语言"]
slug: "spring-struts"
draft: false
lastmod: "2013-03-22T23:23:23Z"
id: 1835262
url: "https://lemo.iteye.com/blog/1835262"
---

1。装载Spring context
2。整合Struts

1。装载Spring context 的方法主要有两种：

（1）在struts-config.xml中配置

<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">

            <set-property peperpty="contextConfigLocation" value="/WEB-INF/classes/applicationContext.xml"/>

</plug-in>

（2）在web.xml中配置

	<context-param>
		<param-name>contextConfigLocation</param-name>
		<param-value>/WEB-INF/classes/applicationContext.xml</param-value>
	</context-param>
	
	<servlet>
		<servlet-name>context</servlet-name>
		<servlet-class>
			org.springframework.web.context.ContextLoaderServlet
		</servlet-class>
		<load-on-startup>1</load-on-startup>
	</servlet>


2。整合Struts方法主要有3种:
(1)用户Action直接继承ActionSupport类，调用getWebApplicationContext().getBean()方法注入所需要的类.

(2)使用Spring的DelegationRequestProcessor代替ActionServlet.
 <!-- 将struts交由spring管理 -->
  <controller processorClass="org.springframework.web.struts.DelegatingRequestProcessor">
  </controller>
(3)使用Spring的委托代理.