Struts2的一些常量和含义的应用
来源:互联网 发布:织梦网站数据采集器 编辑:程序博客网 时间:2024/05/16 07:50
首先,当我们学习一个框架的时,一般可以参考框架自带的示例项目。例如struts2,刚入门的时候,可以参考其自带的blank项目。当部署完这个项目后,开启tomcat服务,在地址栏里输入请求的action路径时,可以发现,虽然没有给该action定义扩展名,但是地址里输入的action路径没有扩展名或者扩展名为action时都可以通过。为什么呢?这是由struts2的默认配置属性决定的。
常量的默认配置在struts2-core-2.1.8.1/org/apache/struts2/default.properties文件里,像定义访问action的默认扩展名、开发模式设置、i18n以及默认字符编码等等,例如struts.action.extension=action,,。
应当注意的是,一般情况不要修改框架系统的原始文件,如果要更改默认的配置项,可以采用覆盖的方式。struts.xml是struts2的基本配置文件之一。该文件内可以配置多个常量,以覆盖默认的常量配置,例如<constant name="struts.action.extension" value="do,," />表示action的可用扩展名为do或者不用扩展名。
常量可以在下面多个文件中进行定义,struts2加载常量的搜索顺序如下,后面的设置可以覆盖前面的设置:
default.properties文件
struts-default.xml
struts-plugin.xml
struts.xml
struts.properties(为了与webwork向后兼容而提供)
web.xml
下面列举几个常用的常量
### This can be used to set your default locale and encoding scheme# struts.locale=en_USstruts.i18n.encoding=UTF-8//指定默认编码
# uses javax.servlet.context.tempdir by defaultstruts.multipart.saveDir=struts.multipart.maxSize=2097152//上传文件大小限制
### Used by the DefaultActionMapper### You may provide a comma separated list, e.g. struts.action.extension=action,jnlp,do### The blank extension allows you to match directory listings as well as pure action names### without interfering with static resources.struts.action.extension=action,,//指定处理请求的后缀
### Used by FilterDispatcher### This is good for development where one wants changes to the static content be### fetch on each request.### NOTE: This will only have effect if struts.serve.static=true### If true -> Struts will write out header for static contents such that they will### be cached by web browsers (using Date, Cache-Content, Pragma, Expires)### headers).### If false -> Struts will write out header for static contents such that they are### NOT to be cached by web browser (using Cache-Content, Pragma, Expires### headers)struts.serve.static.browserCache=true//指定是否缓存静态资源,开发的时候最好关闭
### when set to true, Struts will act much more friendly for developers. This### includes:### - struts.i18n.reload = true### - struts.configuration.xml.reload = true### - raising various debug or ignorable problems to errors### For example: normally a request to foo.action?someUnknownField=true should### be ignored (given that any value can come from the web and it### should not be trusted). However, during development, it may be### useful to know when these errors are happening and be told of### them right away.struts.devMode = false//开发时候设置为trus可以开发出更加详细的信息
### Standard UI theme### Change this to reflect which path should be used for JSP control tag templates by defaultstruts.ui.theme=xhtml//设置默认视图,最好为simple
### Configuration reloading### This will cause the configuration to reload struts.xml when it is changedstruts.configuration.xml.reload=false//设置为True一旦Struts.xml文件修改就自动加载
- Struts2的一些常量和含义的应用
- struts2中一些需要注意的常量
- struts2中一些需要注意的常量
- Struts2中的通配符和常量的说明
- 传智播客-struts2(1)-配置文件里的常量、视图和通配符应用
- ImmGetProperty 对应的常量含义
- struts2 常量的配置
- Struts2的常量详解
- Struts2的常量详解
- struts2的常量
- Struts2 的常量
- Struts2的常量配置
- Struts2的常量配置
- 五、struts2的常量
- Struts2的常量详解
- struts2常量的配置
- struts2的常量配置
- struts2的常量配置
- cc++ 常见试题(1)
- 增加系统调用层次(比如使得系统调用可以传递参数)
- eval解析JSON中的注意点
- 数组中元素旋转移位的三种实现方法 --By LXW
- Oracle Instant Client与Oracle full client
- Struts2的一些常量和含义的应用
- JAVA算法字符串统计
- 写现在女孩的要求
- Solaris重启bfagent服务
- PDF在线编辑器的实现
- js中innerHTML,innerText,outerHTML的用法与区别
- 关于PB调用写有事务开始的存储过程出错的原因
- CMake实践1
- RT-Thread Radio 网络播放器--初次零距离接触!