struts2通用配置文件

来源:互联网 发布:艺卓显示器 知乎 编辑:程序博客网 时间:2024/04/28 13:43

struts.xml

<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts PUBLIC    "-//Apache Software Foundation//DTD Struts Configuration 2.1//EN"    "http://struts.apache.org/dtds/struts-2.1.dtd"><struts>    <!-- 设置统一字符集 -->    <constant name="struts.i18n.encoding" value="UTF-8"></constant>    <!-- 设置为开发模式 -->    <constant name="struts.devMode" value="true"></constant>    <!-- 设置浏览器缓存 -->    <constant name="struts.serve.static.browserCache" value="false"></constant>    <!-- 设置加载国际化资源 -->    <constant name="struts.i18n.reload" value="true"></constant>    <!-- 记载struts配置文件 -->    <constant name="struts.configuration.xml.reload" value="true"></constant>    <!-- 不使用标签自带的样式 -->    <constant name="struts.ui.theme" value="simple"/>         <package name="dang-default" extends="struts-default" namespace="/">    <default-action-ref name="mainAction"/>    <global-results>        <result name="error">            /error.jsp        </result>    </global-results>    <action name="mainAction" class="com.tarena.dang.web.action.MainAction">        <result name="main" type="dispatcher">        /WEB-INF/jsp/main/main.jsp        </result>    </action>         </package>     <include file="config/struts/struts-user.xml"/></struts>

web.xml

<?xml version="1.0" encoding="UTF-8"?><web-app version="2.4"    xmlns="http://java.sun.com/xml/ns/j2ee"    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee    http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">    <filter>        <filter-name>struts2</filter-name>        <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>        <init-param>        <param-name>config</param-name>        <param-value>struts-default.xml,struts-plugin.xml,config/struts/struts.xml</param-value>        </init-param>    </filter>    <filter-mapping>        <filter-name>struts2</filter-name>        <url-pattern>/*</url-pattern>    </filter-mapping>   </web-app>



原创粉丝点击