struts2 笔记

一、生成一个地址
<s:url action="list" id="list"></s:url>
<s:a href="%{list}">list</s:a>

二、struts 常用配置
<!-- 开发模式设置开始 -->
<constant name="struts.devMode" value="true" /> 指定struts的开发模式
<constant name="struts.i18n.reload" value="true" /> 指定struts的资源文件自动重载
<constant name="struts.configuration.xml.reload" value="true" /> 指定struts的配置文件是否自动重载
<constant name="struts.convention.classes.reload" value="true" />Convention类从新加载
<!-- 开发模式结束 -->

<constant name="struts.ul.theme" value="xthml" />指定struts的模板 或者value="simple"
<constant name="struts.locale" value="zh_CN" />地区
<constant name="struts.i18n.encoding" value="UTF-8" />字符集
<constant name="struts.action.extension" value="action,do,jsp" /> 指定struts的扩展名
<constant name="struts.custom.i18n.resource" value="" /> 指定struts的国际化资源文件

三、加载sitemesh
<filter>
    <filter-name>strutsCleanup</filter-name>
    <filter-class>org.apache.struts2.dispatcher.ActionContextCleanUp</filter-class>
</filter>

<filter>
    <filter-name>sitemesh</filter-name>
    <filter-class>com.opensymphony.module.sitemesh.filter.PageFilter</filter-class>
</filter>

<filter>
    <filter-name>struts2Filter</filter-name>
    <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
</filter>

<filter-mapping>
    <filter-name>strutsCleanup</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

<filter-mapping>
    <filter-name>sitemech</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

<filter-mapping>
    <filter-name>struts2Filter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

你可能感兴趣的:(struts2)