Catch-all (wildcard) servlet url-pattern overrides file extension patterns
12,573
I just found a solution through this question: Difference between / and /* in servlet mapping url pattern
Using '/' instead of '/*' did the trick for me.
<servlet-mapping> <servlet-name>myContentServlet</servlet-name> <url-pattern>/</url-pattern> </servlet-mapping>
![Reto Höhener](https://i.stack.imgur.com/fhxGW.png?s=256&g=1)
Author by
Reto Höhener
Updated on June 04, 2022Comments
-
Reto Höhener about 2 years
I would like to achieve the following:
/webapp-context/Page-1 -> Handled by my custom "ContentServlet" /webapp-context/Another-Page -> Handled by my custom "ContentServlet" /webapp-context/Page-with-long-title -> Handled by my custom "ContentServlet" /webapp-context/_cms/<something>.zul -> Handled by ZK framework
My latest attempt looks like this (web.xml extract):
<servlet-mapping> <servlet-name>zkLoader</servlet-name> <url-pattern>*.zul</url-pattern> </servlet-mapping> <servlet-mapping> <servlet-name>myContentServlet</servlet-name> <url-pattern>/*</url-pattern> </servlet-mapping>
Unfortunately now my content servlet handles all requests (I thought the more specific pattern takes precedence?).
No conflict exists if i map my content servlet to the pattern "/webapp-context/content/*", but that's not what I want.
Thanks for your time.