Reputation: 62444
Currently my web.xml shows the following...
<!-- Spring Web MVC dispatcher servlet -->
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>*.html</url-pattern>
<url-pattern>*.json</url-pattern>
</servlet-mapping>
What I'd like to do is limit all .json
URLs to a specific controller. To be honest I'm not entirely sure how DispatcherServlet in Spring works, so I'm not sure if this is on the right track or not.
Upvotes: 0
Views: 1308
Reputation: 1628
The DispatcherServlet follows the request to the right Spring controller. So, depending of your web.xml, you can do this in your web.xml:
<servlet-mapping>
<servlet-name>dispatcher</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
And create a Spring controller, with annotations for instance, like:
@Controller
@RequestMapping(value = "/*.json")
public class TheController {
}
Some usefull resources: http://blog.netapsys.fr/index.php/post/2008/04/13/Introduction-A-Spring-MVC http://static.springsource.org/docs/Spring-MVC-step-by-step/
Upvotes: 1