struts常量和struts.xml配置文件分解配置
来源:互联网 发布:惠灵顿牛排 知乎 编辑:程序博客网 时间:2024/05/16 14:14
一:struts常量①常量可以在struts.xml或struts.properties(放在src下)中配置,推荐在struts.xml中配置(最好把需要配置的常量统一配置到这个文件里面).
②因常量可在多个配置文件中进行定义,struts2加载常量的搜索顺序:
1 struts-default.xml
2 struts-plugin.xml
3 struts.xml
4 struts.properties
5 web.xml
如在多个文件中配置同一个常量,则后一个文件中配置的常量值会覆盖前一个文件配置的常量值.按搜索顺序,以最后的设定值为准。
③常用的一些常量: 指定默认编码集,作用于HttpServletRequest的setCharacterEncoding方法和freemarker 、velocity输出
<constant name="struts.i18n.encoding" value="UTF-8"/>
指定需要Struts 2处理的请求后缀,默认是action,如用户需指定多个请求后缀,则多个后缀之间以英文逗号(,)隔开
<constant name="struts.action.extension" value="do"/>
设置浏览器是否缓存静态内容,默认值为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" />
默认视图主题
<constant name="struts.ui.theme" value="simple" />
与spring集成时,指定由spring负责action对象的创建
<constant name="struts.objectFactory" value="spring" />
该属性设置Struts 2是否支持动态方法调用(默认值是true)
<constant name="struts.enable.DynamicMethodInvocation" value="false"/>
上传文件大小限制
<constant name="struts.multipart.maxSize" value=“10701096"/>
二:struts.xml配置文件分解配置
1 struts-default.xml
2 struts-plugin.xml
3 struts.xml
4 struts.properties
5 web.xml
如在多个文件中配置同一个常量,则后一个文件中配置的常量值会覆盖前一个文件配置的常量值.按搜索顺序,以最后的设定值为准。
<constant name="struts.i18n.encoding" value="UTF-8"/>
指定需要Struts 2处理的请求后缀,默认是action,如用户需指定多个请求后缀,则多个后缀之间以英文逗号(,)隔开
<constant name="struts.action.extension" value="do"/>
设置浏览器是否缓存静态内容,默认值为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" />
默认视图主题
<constant name="struts.ui.theme" value="simple" />
与spring集成时,指定由spring负责action对象的创建
<constant name="struts.objectFactory" value="spring" />
该属性设置Struts 2是否支持动态方法调用(默认值是true)
<constant name="struts.enable.DynamicMethodInvocation" value="false"/>
上传文件大小限制
<constant name="struts.multipart.maxSize" value=“10701096"/>
在大部分应用里,随着应用规模增大,Action数量会大量增加,导致struts.xml配置文件变得臃肿。为了避免struts.xml文件过于庞大、臃肿,提高并发开发效率,增强配置文件文件可读性,可将一个struts.xml配置文件分解成多个配置文件,在struts.xml文件中引入这些配置文件。分解的配置子文件名字任意。
图示的子配置文件配置到struts.xml 中。
配置到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="true" /><constant name="struts.devMode" value="false" /><constant name="struts.custom.i18n.resources" value="fileuploadresource" /> <include file="com/tianci/struts2_1/struts_test_1.xml" /> <!-- file的值是完整的相对路径。 --></struts>
<?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="true" /><constant name="struts.devMode" value="false" /><constant name="struts.custom.i18n.resources" value="fileuploadresource" /> <include file="com/tianci/struts2_1/struts_test_1.xml" /> <!-- file的值是完整的相对路径。 --></struts>
1 0
- struts常量和struts.xml配置文件分解配置
- struts.xml常量配置
- 详解struts.xml配置文件constant常量配置问题
- struts.xml常用常量配置
- Struts.xml 常用常量配置
- struts.xml配置文件基本配置
- 5.struts.xml配置常量和Action处理流程
- 把struts2的struts.xml配置文件分解成多个配置文件
- 把struts2的struts.xml配置文件分解成多个配置文件
- 把struts2的struts.xml配置文件分解成多个配置文件
- Struts2配置文件复用代码【web.xml、struts.xml、常量配置】
- Struts 2核心配置文件struts.properties和struts.xml
- struts.xml中配置常量constant详解
- struts.xml 中配置常量constant详解
- struts.xml 中配置常量constant详解
- struts.xml 中配置常量constant详解
- struts.xml 中配置常量constant详解
- struts2 struts.xml常用常量配置
- 基于maven的web项目在Eclipse中使用Tomcat调试
- Android 监听短信(同时监听广播和数据库)
- 如何修改织梦的提示页面
- PostgreSQL学习手册(模式schema)
- hadoop常用命令笔记
- struts常量和struts.xml配置文件分解配置
- <meta />标签用法总结
- HDU1003——Max Sum
- 使用Java构建微服务
- linux_命令_压缩解压01
- iOS应用架构谈(一):架构设计的方法论
- Xcode工程使用CocoaPods管理第三方时,出现diff: /../Podfile.lock: No such file or directory diff: /Manifest.lock:
- StringBuilder与StringBuffer
- Java核心技术笔记——数据结构(1)