Put请求一般可用来修改服务器中的资源,但如果你需要提交给服务器一些表单数据,那么遗憾的告诉你,PUT请求不支持,最简单的方法就是改用POST请求,我也是今天在项目中才知道的,特此记下,共同学习。
具体请看:
SRV.4.1.1 When Parameters Are Available
The following are the conditions that must be met before post form
data will be populated to the parameter set:
1. The request is an HTTP or HTTPS request.
2. The HTTP method is POST.
3. The content type is application/x-www-form-urlencoded.
4. The servlet has made an initial call of any of the getParameter
family of methods on the request object.
大概意思是:
以下条件是在post form数据在被移至参数集合之前必须满足的条件:
1. request是HTTP/HTTPS request
2. HTTP method是POST。
3. content type是application/x-www-form-urlencoded。
4. servlet已经对request对象中所有getParameter可以得到的参数做了初始化调用。