Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
222 views
in Technique[技术] by (71.8m points)

java - Filter mapping for everything to Struts2 besides one servlet?

I have a Struts2 (2.1.8.1) web application. My web.xml looks like,

  <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>

This is configured to map all requests to the struts filter. I want to add a servlet in my web application. I want to send all requests with a certain url pattern to that servlet. I want everything else to go to my struts servlet.

I know I could only map "*.action" to the struts servlet, but I hate .action being on the end of all my URL's.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

In your struts.xml add:

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

The value be comma delimited as well for multiple exclusions. See http://struts.apache.org/2.2.1/docs/webxml.html


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...