On 12/10/2016 08:02, Mladen Adamović wrote:
> Lets assume that web.xml has a rule
>     <servlet-mapping>
>             <servlet-name>One</servlet-name>
>             <url-pattern>/something/e*</url-pattern>
>     </servlet-mapping>
> While class Two.class has an annotation:
>     @WebServlet(name = "Two", urlPatterns = {"/something/er*"})
> From the Servlet 3.0 specification
> 8.2.3. (point 4). `The web.xml of the web application has the highest
> precedence when resolving conflicts between the web.xml, web-fragment.xml
> and annotations.`

Note that the order of precedence is:
web.xml -> web-fragment.xml -> annotations

> While 12.2 states: The container will recursively try to match the longest
> path-prefix. This is done by stepping down the path tree a directory at a
> time, using the ’/’ character as a path separator. The longest match
> determines the servlet selected.
> So for the request /something/error Tomcat will choose Two.class?

No. Neither will match. Prefix matches have to end with "/*". The two
mappings above are exact matches.

> And more general, in the case there are both annotation and web.xml rule
> with the same prefix length, it will choose a first occurrence in web.xml?

The mapping from web.xml will be used.

If there are two mappings in web.xml with identical URL patterns then an
error will occur.


To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org

Reply via email to