Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Catch-all (wildcard) servlet url-pattern overrides file extension patterns

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.

like image 765
Reto Höhener Avatar asked Dec 03 '12 22:12

Reto Höhener


1 Answers

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>
like image 116
Reto Höhener Avatar answered Sep 30 '22 06:09

Reto Höhener