Friday, July 05, 2013

Enable static contents in Spring MVC

According to Spring MVC documentation , adding the following bean configuration would do the work for DispatcherServlet serving static content:
 mapping="/resources/**" location="/public-resources/"/>
However, people tend to overlook the following 2 steps in order to make it completely work:
1. mvc:annotation-driven needs to be added as well. Otherwise, the above configuration would block DispatcherServlet to dispatch other dynamic content to controllers.
2. Make sure request path for those static content is correct, i.e., including context path.

No comments: