调用request.getParamter()后获取body为空

3.1.1 When Parameters Are Available
The following are the conditions that mustbe 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 getParameterfamily of methods 
on the request object.
If the conditions are not met and the post form data is not included in the parameter 
set, the post data must still be available to the servlet via the request object’s input 
stream. If the conditions are met, post form data will no longer be available for 
reading directly from the request object’s input stream.

 

经过翻译servlet上面一段规范如下:

根据Servlet规范,如果同时满足下列条件,则请求体(Entity)中的表单数据,将被填充到request的parameter集合中(request.getParameter系列方法可以读取相关数据):
1 这是一个HTTP/HTTPS请求
2 请求方法是POST(querystring无论是否POST都将被设置到parameter中)
3 请求的类型(Content-Type头)是application/x-www-form-urlencoded
4 Servlet调用了getParameter系列方法

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值