We are currently using a Jersey JAX-RS implementation to handle our REST requests (server-side Jersey). Our web.xml file is configured so all /rest/* requests are handled by
First, when it comes to servlet mapping, priority goes like this:
/rest/*
*.png
/
So you can't map static resources by their file extension within an existing path mapping (that would be a bad idea anyway, managing all static file extensions in your web.xml).
Path mapping's priority > ext mapping.
Set up an UrlRewriteFilter in your web.xml
<filter>
<filter-name>UrlRewriteFilter</filter-name>
<filter-class>org.tuckey.web.filters.urlrewrite.UrlRewriteFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>UrlRewriteFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
And in your urlrewrite.xml
configuration file:
<urlrewrite default-match-type="wildcard">
<rule>
<from>/rest/images/**</from>
<to>/images/$1</to>
</rule>
</urlrewrite>
This may not suit your needs, but this is my favorite!
Mapping static resources within /rest
says "Hey, developer, come GET/POST/PUT/DELETE thoses static resources, it's okay":
/rest
. It gives the wrong impression.This is pretty easy to achieve. Just register Jersey ServletContainer in web.xml as a filter (instead of servlet) - see the bottom of this page for an example - and either use ServletContainer.PROPERTY_WEB_PAGE_CONTENT_REGEX or ServletContainer.FEATURE_FILTER_FORWARD_ON_404 init param to make the static content accessible.