My dispatcher servlet maps to the root of the app.
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
I have a folder called 'static' in my webroot. It contains CSS, JS and image files. However, because of the dispatcher servlet mapping, the requests for static contents end up in 404s.
I know the solutions lying around to address this.
Make dispatcher map to a more specific URL, say :context:/app/, and then write a filter to intercept requests, and map conditionally to the default servlet, or else delegate to the spring dispatcher.
The URL rewrite trick.
using
<mvc:resources />
Problem is, my mappings are XML based, and I will absolutely not scatter my mappings config all over the place in the name of using annotations. So if I use <mvc:resources />, my xml based mappings break, and all url mappings to different controllers are lost.
This is becase <mvc:resources /> overrides some settings and applies its own. But it is also the cleanest solution for static content.
Any way available to tell <mvc:resources /> to not override my xml based mappings?