<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.3//EN"
"http://struts.apache.org/dtds/struts-2.3.dtd">
<struts>
<!-- 指定默认编码集,作用于HttpServletRequest的setCharacterEncoding方法 和freemarker 、velocity的输出 -->
<constant name="struts.i18n.encoding" value="UTF-8"/>
<!-- 设置浏览器是否缓存静态内容,默认值为true(生产环境下使用),开发阶段最好关闭 -->
<constant name="struts.serve.static.browserCache" value="false"/>
<!-- 当struts的配置文件修改后,系统是否自动重新加载该文件,默认值为false(生产环境下使用),开发阶段最好打开 -->
<constant name="struts.configuration.xml.reload" value="true"/>
<!-- 开发模式下使用,这样可以打印出更详细的错误信息 -->
<constant name="struts.devMode" value="true" />
<package name="basemanage" extends="json-default" namespace="/base">
<!-- 拦截器配置 -->
<interceptors>
<interceptor name="loginInterceptor"
class="cn.tdtk.right.interceptor.LoginInterceptor">
</interceptor>
<interceptor-stack name="loginStack">
<interceptor-ref name="loginInterceptor"></interceptor-ref>
<interceptor-ref name="defaultStack"></interceptor-ref>
</interceptor-stack>
</interceptors>
<!-- 默认拦截器,此包下所有的ACTION将都被拦截。如果ACTION再定义了拦截器,则失效 -->
<default-interceptor-ref name="loginStack"></default-interceptor-ref>
<global-results>
<!-- 全局视图配置-->
<result name="login">/page/LoginPlatform.jsp</result>
<result name="error">/page/404.htm</result>
</global-results>
<include file="/struts2.xml"></include> --引入配置文件,可以减少文件膨胀
</struts>
--------------------------------------------------------------------------------------------------------------------------
struts2.xml文件,它的action是通过spring注入的。
<package name="suppl" extends="json-default" namespace="/suppl">
<action name="supplAlterHisAction" class="supplAlterHisAction">
<result name="success" type="json">
<param name="root">map</param>
</result>
</action>
<action name="supplAlterHisAction" class="supplAlterHisAction">
</action>
<action name="downloadAction" class="supplAlterHisAction">
<result>
<param name="contentType">text/html</param>
</result>
</action>
</package>
--------------------------------------------------------------------------------------------------------------------------
spring配置文件,管理action
<?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.xsd">
<!-- DAO层注入 -->
<bean id ="supplAlterHisDao" class="cn.dao.impl.SupplAlterRecordDaoImpl">
<property name="hibernateTemplate" ref="hibernatetemplate"></property> 应用hibernate的模板
</bean>
<!-- service层注入 -->
<bean id ="supplAlterHisService" class="cn.service.impl.SupplAlterRecordServiceImpl">
<property name="supplAlterHisDao" ref="supplAlterHisDao"></property>
</bean>
<!-- action层注入 -->
<bean id ="supplAlterHisAction" class="cn.action.SupplAlterRecordAction" scope="prototype">
<property name="supplAlterHisService" ref="supplAlterHisService"></property>
</bean>
</beans>