@RequestBody入参Unsupported Media Type
{ "timestamp": "2021-12-23T07:41:22.848+00:00", "status": 415, "error": "Unsupported Media Type", "message": "", "path": "/hotel/search" } |
postman设置form-data或者x-www-form-urlencoded时如下报错:
WARN o.s.w.s.m.support.DefaultHandlerExceptionResolver – Resolved [org.springframework.web.HttpMediaTypeNotSupportedException: Content type ‘application/x-www-form-urlencoded;charset=UTF-8’ not supported]
o.s.w.s.m.support.DefaultHandlerExceptionResolver – Resolved [org.springframework.web.HttpMediaTypeNotSupportedException: Content type ‘multipart/form-data;boundary=————————–229317153710789361510599;charset=UTF-8’ not supported]
1. postman可以使用raw发送请求
2. ajax发送请求设置contentType类型,如果想用 @RequestBody注解做提交json字符串自动绑定到pojo入参时,类型需要是”application/json;charset=UTF-8″,否则会抛”not supported”异常。