代码之家  ›  专栏  ›  技术社区  ›  Andy

除了一个servlet之外,所有东西的过滤器映射到struts2?

  •  6
  • Andy  · 技术社区  · 16 年前

    我有一个Struts2(2.1.8.1)Web应用程序。我的web.xml看起来,

      <filter>
        <filter-name>struts2</filter-name>
        <filter-class>org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter</filter-class>
      </filter>
    
      <filter-mapping>
        <filter-name>struts2</filter-name>
        <url-pattern>/*</url-pattern>
      </filter-mapping>
    

    这被配置为将所有请求映射到Struts过滤器。我想在我的Web应用程序中添加一个servlet。我想将具有特定URL模式的所有请求发送到该servlet。我想把其他的东西都放到我的Struts servlet上。

    我知道我只能将“*.action”映射到struts servlet,但我讨厌.action位于所有URL的末尾。

    1 回复  |  直到 9 年前
        1
  •  13
  •   Matt    16 年前

    在struts.xml中添加:

    <constant name="struts.action.excludePattern" value="/ServletToExcludeFromStruts*"/>
    

    对于多个排除项,该值也用逗号分隔。见 http://struts.apache.org/2.2.1/docs/webxml.html