struts配置访问后缀为.do,.action,.*

Struts 配置文件的加载顺序

    Struts-default.xml---> struts-plugin.xml--> struts.xml-->   struts.properties--> web.xml

如果在多个配置文件中定义了同一个常量,则后面的会覆盖前面 的

1)

Struts2 默认是支持/* 和 *.action的匹配,配置如下:

 

Web.xml

 

   <filter-mapping>

      <filter-name>struts2</filter-name>

      <url-pattern>/*</url-pattern>

   </filter-mapping>

 

或者

 

   <filter-mapping>

      <filter-name>struts2</filter-name>

      <url-pattern>/*</url-pattern>

      <url-pattern>*.action</url-pattern>

      <url-pattern>*.do</url-pattern>

   </filter-mapping>

 

struts.xml

及其他配置文件中不能指定

 

<constant name="struts.action.extension" value="do" />

struts.action.extension属性

 

假如:

   <constant name="struts.action.extension" value="do" />

 

属性一旦被指定,只能匹配指定的后缀请求。

 

2)同时支持/*,*.action *.do的请求

 

修改struts2-core-2.2.3.jar包中的orgapachestruts2目录下的default.properties 文件中的

struts.action.extension=action,,

struts.action.extension=action,do,

 

web.xml中

<filter-mapping>

      <filter-name>struts2</filter-name>

      <url-pattern>/*</url-pattern>

      <url-pattern>*.action</url-pattern>

      <url-pattern>*.do</url-pattern>

   </filter-mapping>

原文地址:https://www.cnblogs.com/liangbo-/p/7307145.html