关于出现“Content type ‘application/x-www-form-urlencoded;charset=UTF-8‘ not supported“问题如何解决

编程知识 更新时间:2023-04-05 06:07:34

所遇问题

在公司开发项目中,当前端传来参数时,前端却报错,报错信息显示”Content type ‘application/x-www-form-urlencoded;charset=UTF-8’ not supported“

原因

此问题的原因是因为前后端数据交互出现json数据类型不符合
json 分为两种类型;
(1) json 对象类型,即前端定义的Content type 为 application/x-www-form-urlencoded等
(2) json字符串类型,即前端定义的Content type 为 application/json

解决办法

前端传输的json数据类型和后端使用的注解应有正确的对应关系
当前端请求传Json对象则后端使用@RequestParam注解;
当前端请求传Json对象的字符串则后端使用@RequestBody注解。

更多推荐

关于出现“Content type ‘application/x-www-form-urlencoded;charset=UTF-8‘ not supporte

本文发布于:2023-04-05 06:07:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/1e1de8544939ddeafa10c03d1e39e7a5.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何解决   application   www   Content   type

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!

  • 45183文章数
  • 14阅读数
  • 0评论数