服务器交互的不同方法
GET,POST,PUT,DELETE
URL资源
HTTP中的PUT,DELETE,POST,GET就对应着对这个URL资源的增,删,改,查4个操作。
GET一般用于获取/查询资源信息,而POST一般用于更新资源信息。
MVC框架设计问题
早期的Web MVC框架设计者们并没有意识到将URL当作抽象的资源来看的重要性,导致一个的问题是传统的Web MVC框架基本上都只支持GET和POST两种HTTP方法,而不支持PUT和DELETE方法。而Spring MVC是全部支持的。
如何使用PUT/DELETE
表单
这里提交了一个_method的参数
<form action="/put" method="post">
<input type="hidden" name="_method" value="PUT" />
<input type="submit" value="submit" />
</form>
HiddenHttpMethodFilter
SpringMVC 在页面访问要通过此过滤器
/*
* Copyright 2002-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.a