问题描述
@RequestMapping(value = "/Save",method = RequestMethod.POST,consumes = {"application/json;charset=ISO-8859-1" },produces = {"application/json;charset=ISO-8859-1" })
public SaveResponse save(@RequestBody SaveRequest request) {
//some codes
}
}
我的请求包含以下几行
{
:
:
"mailingAddress": {
"addressLine1": "Carrera 36E N°","addressLine2": "Medellín,Antioquia","country": "COL"
}
:
HTTP/1.1 400 Bad Request
Cache-Control: no-cache,no-store,max-age=0,must-revalidate
Date: Wed,16 Jun 2021 12:26:37 GMT
Pragma: no-cache
Content-Length: 0
Expires: 0
x-frame-options: DENY
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
X-RBT-Optimized-By: CANA014IJT (RiOS 6.1.1a #11) SC
当我从请求中删除字符“°”和“í”时,请求可以顺利通过。我的问题是什么?
谢谢。
解决方法
您可以尝试将字符集从 ISO-8859-1 更改为 UTF-8,因为前者不支持如此宽的字符映射数组 (What is the difference between UTF-8 and ISO-8859-1?)。