spring配置文件都放到src/conf/spring目录中,struts.xml放在src目录下
1、web.xml配置如下
修改struts.xml,
所有action类都继承 com.opensymphony.xwork2.ActionSupport
1、web.xml配置如下
<context-param>
<param-name>webAppRootKey</param-name>
<param-value>b2b.root</param-value>
</context-param>
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/log4j.properties</param-value>
</context-param>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:conf/spring/spring*.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>OpenSessionInViewFilter</filter-name>
<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
<init-param>
<param-name>singleSession</param-name>
<param-value>false</param-value> <!--设置成false,才能保证在jsp页面调用Bean中的lazy对象时不会出错-->
</init-param>
</filter>
<filter-mapping>
<filter-name>OpenSessionInViewFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
修改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.enable.DynamicMethodInvocation" value="false"/>
<constant name="struts.devMode" value="true"/>
<constant name="struts.i18n.encoding" value="UTF8"/>
<package name="default" namespace="/" extends="struts-default">
<global-results>
<result name="businessError">/pages/errors/BusinessErrorPage.jsp</result>
<result name="dbError">/pages/errors/DBErrorPage.jsp</result>
<result name="httpError">/pages/errors/HTTPErrorPage.jsp</result>
<result name="permissionError">/pages/errors/PermissionErrorPage.jsp</result>
<!-- 当Session失效时,统一转到这个页面 -->
<result name="login" type="redirectAction">Login_input</result>
<result name="json" type="json"></result>
<result name="error">/pages/bp/errorPage.jsp</result>
</global-results>
<global-exception-mappings>
<exception-mapping result="businessError" exception="XXXException"></exception-mapping>
<exception-mapping result="httpError" exception="XXXXException"></exception-mapping>
</global-exception-mappings>
</package>
<include file="struts_*.xml"/>
</struts>
所有action类都继承 com.opensymphony.xwork2.ActionSupport