默认情况下,struts2是无法处理以.do为后缀的url请求(默认情况下是.action或者不填,可以参见org.apache.struts2包下的default.properties文件)
但是strurts是一个高配置的框架,所以我们可以通过配置来处理以do为后缀的请求。
struts2提供了一系列的常量来供我们配置。
如:我们可以在Struts.xml文件来配置
constant name="struts.action.extension" value="do"
如果配置多个,可以以逗号分隔开
如:
是其能够处理以do为后缀的url请求,同时我们也可以通过资源文件的方式来配置
可以在我们项目的类路劲下创建一个struts.properties文件
然后可以在此资源文件中加入,引用
struts.action.extension=do
struts2还提供了其他方式来加载常量,推荐正在Struts.xml文件中配置
Struts2加载常量的顺序是:
struts-default.xml
struts-plugin.xml
struts.xml
struts.properties
web.xml
我们可以通过启动tomcat时控制台打印结果可以看到:
引用
信息: Parsing configuration file [struts-default.xml]
2009-12-10 22:47:46 com.opensymphony.xwork2.util.logging.jdk.JdkLogger info
信息: Unable to locate configuration files of the name struts-plugin.xml, skipping
2009-12-10 22:47:46 com.opensymphony.xwork2.util.logging.jdk.JdkLogger info
信息: Parsing configuration file [struts-plugin.xml]
2009-12-10 22:47:46 com.opensymphony.xwork2.util.logging.jdk.JdkLogger info
信息: Parsing configuration file [struts.xml]