struts2處理.do後綴de請求

默認狀況下,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

Java代碼 複製代碼 收藏代碼blog

  1.  

是其可以處理以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]

相關文章
相關標籤/搜索