application/x-www-form-urlencoded;charset=UTF-8 not supported 错误解决

在做ajax请求时,会发生如图中的错误

org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported

Paste_Image.png

解决方法如下:
ajax请求加上这句话:

contentType: "application/json"
application/x-www-form-urlencoded;charset=UTF-8 not supported 错误解决_第1张图片
Paste_Image.png

问题就可以搞定,json化自己对象后,必须声明数据传输类型为json格式

你可能感兴趣的:(application/x-www-form-urlencoded;charset=UTF-8 not supported 错误解决)