struts.xml和struts.properties文件的格式我就不再赘述了,随便一本讲框架的书上都说的很详细,struts2的官网上也有。
官网:http://struts.apache.org/
主要记录一些注意事项:
struts.xml
1、package可以继承,使用extends属性名。
2、package的namespace属性中”/”与空是一致的,但是”/”只能接受来自根目录的请求,比如localhost:8080/[YOURWEBAPP]/do.action两者都可以接受,但是localhost:8080/[YOURWEBAPP]/subpath/do.action的请求”/”就不能接受了
struts.properties可以用来方便的管理常量,比如编码问题,在
struts.xml里需要用constant元素来标示
<constant name="struts.i18n.encoding" value="utf-8">
web.xml里使用初始化参数来标示
<filter>
...
<init-param>
<param-name>struts.i18n.encoding</param-name>
<param-value>utf-8</param-value>
</init-param>
...
</filter>
在struts.properties里就很简单了
struts.i18n.encoding = utf-8
就ok