web.xml
<filter>
<!-- 定义核心Filter的名字 -->
<filter-name>struts2</filter-name>
<!-- 定义核心Filter的实现类 -->
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
</filter>
<!-- FilterDispatcher用来初始化Struts 2并且处理所有的Web请求 -->
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
struts.xml
<?xml version="1.0" encoding="GBK"?>
<!-- 指定Struts 2配置文件的DTD信息 -->
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<!-- struts是Struts 2配置文件的根元素 -->
<struts> <include file="strutsa.xml" />
<!-- Struts 2的Action必须放在指定的包空间下定义 -->
<package name="strutsall" extends="struts-default">
</package>
</struts>
strutsa.xml
<?xml version="1.0" encoding="GBK"?>
<!-- 指定Struts 2配置文件的DTD信息 -->
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<!-- struts是Struts 2配置文件的根元素 -->
<struts>
<!-- Struts 2的Action必须放在指定的包空间下定义 -->
<package name="strutsa" extends="struts-default">
<!-- 定义login的Action,该Action的实现类为lee.Action类 -->
<!--<action name="Login" class="myaction.LoginAction">-->
<action name="myLogin" class="loginAction">
<!-- 定义处理结果和资源之间映射关系。 -->
<result name="error">/error.jsp</result>
<result name="success">/welcome.jsp</result>
<result name="admin">/admin.jsp</result>
</action>
</package>
<constant name="struts.objectFactory" value="spring" />
</struts>
applicationContext.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dwr="http://www.directwebremoting.org/schema/spring-dwr"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.directwebremoting.org/schema/spring-dwr
http://www.directwebremoting.org/schema/spring-dwr-2.0.xsd">
<!-- 要加上以上粗体部分 -->
<dwr:configuration>
<dwr:convert type="bean" class="mydwr.Chat"></dwr:convert>
<dwr:convert type="bean" class="mydwr.User"></dwr:convert>
</dwr:configuration>
<bean id="chatServer" class="mydwr.SendPush">
<dwr:remote javascript="ChatServer">
</dwr:remote>
</bean>
<bean id="myservice" class="my.MyServiceImpl"/>
<bean id="loginAction" class= "my.LoginAction" scope="prototype">
<property name="ms" ref="myservice"/>
</bean>
</beans>
web.xml
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<!-- ContextLoaderListener -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
struts2-spring-plugin-2.0.14.jar(struts里有)
spring-beans-2.0.5.jar(struts里有)
spring-context-2.0.5.jar(struts里有)
spring-core-2.0.5.jar(struts里有)
spring-web-2.0.5.jar(struts里有)
org.springframework.aop-3.0.4.RELEASE.jar(来自spring)