【发布时间】:2016-02-04 11:47:49
【问题描述】:
我正在使用以下代码发送POST 请求,但该请求以分块(Transfer-Encoding: chunked)的形式发送。我用谷歌搜索了这个问题,它说要包含Content-Length,但在下面的代码中我不知道如何设置Content-Length:
@RequestMapping(value = "/contacts", method = RequestMethod.POST)
public Map<String, ContactInfo> addContactInfo(
@RequestBody Map<String, ContactInfo> ContactInfoDto) {
ContactInfo contactInfo = ContactInfoDto.get("contact");
if (contactInfo == null) {
throw new IllegalArgumentException("Contact not found.");
}
contactInfo = this.contactInfoManager.addNew(contactInfo);
Map<String, ContactInfo> map = new HashMap<>();
map.put("contact", contactInfo);
return map;
}
【问题讨论】:
-
你得到答案了吗?
-
我相信是响应,而不是请求,它是以面向块的方式传输的
-
@RamDuttShukla 是请求还是响应你要设置
Content-Length就可以了? -
@AliDehghani 作为回应。
标签: java spring spring-mvc