struts2+spring整合最小配置

==================
jars
==================
commons-fileupload-1.2.1.jar
commons-io-1.3.2.jar
commons-logging-1.0.4.jar
antlr-2.7.2.jar
log4j-1.2.15.jar

struts2-core-2.1.6.jar
struts2-spring-plugin-2.1.6.jar
xwork-core-2.1.6.jar
freemarker-2.3.13.jar

org.springframework.asm-3.0.0.RELEASE.jar
org.springframework.beans-3.0.0.RELEASE.jar
org.springframework.context-3.0.0.RELEASE.jar
org.springframework.context.support-3.0.0.RELEASE.jar
org.springframework.core-3.0.0.RELEASE.jar
org.springframework.expression-3.0.0.RELEASE.jar
org.springframework.web-3.0.0.RELEASE.jar

==================
web.xml
==================
<?xml version="1.0" encoding="gb2312"?>
<web-app version="2.4" 
	xmlns="http://java.sun.com/xml/ns/javaee" 
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
	xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
	http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
  <welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
  </welcome-file-list> 
  <filter>
  	<filter-name>struts2</filter-name>
  	<filter-class>
       org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
   	</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>*.do</url-pattern>
  </filter-mapping>
  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> 
  </listener>
  <context-param>
    <param-name>contextConfigLocation</param-name> 
    <param-value>/WEB-INF/classes/applicationContext.xml</param-value> 
  </context-param>
</web-app>

==================
struts.xml:(方式一)
==================
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
    "-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
    "http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
    <constant name="struts.objectFactory" value="spring" />
    <constant name="struts.action.extension" value="do" />
    <constant name="struts.devMode" value="true" />
 
    <package name="user" extends="struts-default">
		<action name="*_*" class="com.abc.action.{1}Action" method="{2}">
			<result name="SUCCESS">/success.jsp</result>
		</action>
		<action name="*" class="com.abc.action.{1}Action">
			<result name="SUCCESS">/success.jsp</result>
		</action>
    </package>
</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"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">	
           
	<bean id="userService" class="com.abc.service.UserService"/>
</beans>

==================
log4j.properties
==================
log4j.rootLogger=info, stdout, file

log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n

log4j.appender.file=org.apache.log4j.FileAppender
log4j.appender.file.File=d:\log4j.log
log4j.appender.file.layout=org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n






你可能感兴趣的:(SSH整合)