I am developing a webapp using Spring MVC 3 and have the DispatcherServlet
catching all requests to \'/\' like so (web.xml):
My own experience with this problem is as follows. Most Spring-related web pages and books seem to suggest that the most appropriate syntax is the following.
The above syntax suggests that you can place your static resources (CSS, JavaScript, images) in a folder named "resources" in the root of your application, i.e. /webapp/resources/.
However, in my experience (I am using Eclipse and the Tomcat plugin), the only approach that works is if you place your resources folder inside WEB_INF (or META-INF). So, the syntax I recommend is the following.
In your JSP (or similar) , reference the resource as follows.
Needless to mention, the entire question only arose because I wanted my Spring dispatcher servlet (front controller) to intercept everything, everything dynamic, that is. So I have the following in my web.xml.
front-controller
org.springframework.web.servlet.DispatcherServlet
1
front-controller
/
Finally, since I'm using current best practices, I have the following in my front controller servlet xml (see above).
And I have the following in my actual controller implementation, to ensure that I have a default method to handle all incoming requests.
@RequestMapping("/")
I hope this helps.