1、默认常量配置:
(1)配置文件位置:
(2)配置文件:
以键值对的方式存储。
2、配置文件的修改:
(1)在src目录下新建一个file(名字为struts.properties),在里面写入要修改的键值对。
(2)在struts.xml中配置:
(3)在web.xml中进行配置:
3、配置文件详解(这里采用方式二对配置文件进行修改):
(1)struts.i18n.encoding=UTF-8:解决post提交乱码
(2)struts.action.extension=action,,:指定访问action的后缀名,可以为空或“.action”
后缀为空的情况:
后缀为.action的情况:
如果修改为必须以abc结尾:
没有加abc后缀的话:
加上后缀之后能够正常访问:
(3)struts.devMode = false:指定Struts2是否以开发模式运行:
注释:
### 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.
(1)热加载主配置文件(不需要重启服务器修改的配置文件即可生效)
(2)提供更多错误信息输出,方便开发时的调试