- I wanna map all request to the TestHandler Servlet, so I use
/*
pattern. - Then I wanna exclude jsp mappings, so I add
*.jsp
pattern mapping to jsp in front of/*
. - Problem: .jsp doesn't catch the url
http://localhost/project/fun.jsp
at all. In stead, / pattern catches it. Why? How can this happen ?
<servlet-mapping>
<servlet-name>jsp</servlet-name>
<url-pattern>*.jsp</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>TestHandler</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
But if I use a certain url-pattern like fun.jsp
instead of *.jsp
, it works. The fun.jsp
pattern catch the url above. Who can tell me why ?
Best Answer
The patterns ending with
/*
(path rules) are matched before the*.
starting (extension rules) mappings. The exact URI is an exact match, which is the 1st in the evaluation order.Set
TestHandler
as default servlet, that should work.