默认状况下,struts2是没法处理以.do为后缀的url请求(默认状况下是.action或者不填,能够参见org.apache.struts2包下的default.properties文件)web
可是strurts是一个高配置的框架,因此咱们能够经过配置来处理以do为后缀的请求。apache
struts2提供了一系列的常量来供咱们配置。tomcat
如:咱们能够在Struts.xml文件来配置框架
constant name="struts.action.extension" value="do"url
若是配置多个,能够以逗号分隔开
如:xml
是其可以处理以do为后缀的url请求,同时咱们也能够经过资源文件的方式来配置ip
能够在咱们项目的类路劲下建立一个struts.properties文件资源
而后能够在此资源文件中加入,引用get
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]