简体   繁体   中英

Filter mapping servlet with url pattern **

The difference between * and ** should be : * matches until "/" while ** matches every path including "/" . I noticed that for filter mapping in web xml "/*" is working even for paths with multiple "/" eg :

<filter>
    <filter-name>loginFilter</filter-name>
    <filter-class>..LoginFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>loginFilter</filter-name>
    <url-pattern>/test/*</url-pattern>
</filter-mapping>

this will match /test/...../....

so is this specific to filter mapping ? is servlet mapping the same or it works with ** ?


This mapping is done in project's (Spring Data ) web.xml not the tomcat , I'm not sure if it's different.

I have also tried tomcat web.xml and it seems "/*" will work for all paths with "/" , the question will be when "/**" is applicable ?

Ant-style patterns with "**" do not work in a web.xml file. See the Servlet specification chapter "12.2 Specification of Mappings" for details on what mappings are allowed. The options are rather limited. The '*' character is used in prefix mapping and extension mapping only. In all other cases it is interpreted literally (for exact matching).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM