使用SpringMVC实现RESTful风格

首先在web.xml中加入一个HiddenHttpMethodFilter过滤器。 它可以实现http请求方法的转换,将post或get请求转换成delete或put。这样的好处是,只是用同一个url就能对资源做CRUD操作。

method org.springframework.web.filter.HiddenHttpMethodFilter method /*

【使用SpringMVC实现RESTful风格】最后在jsp页面中,通过隐式表单域指明真正需要执行的方法
使用SpringMVC实现RESTful风格
文章图片
JSP1.png 使用SpringMVC实现RESTful风格
文章图片
JSP2.png 最后就是在Controller中通过注解来指明哪个请求执行什么方法。
使用SpringMVC实现RESTful风格
文章图片
controller.png

    推荐阅读