我POST
使用以下代码发送请求,但请求以chunked(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;
}
Run Code Online (Sandbox Code Playgroud)