The server refused this request because the request entity is in a format not supported by 415错误

当在SpringMVC后台方法使用@RequestBody注解接收参数时,遇到服务器因请求实体格式不支持而拒绝请求的问题。解决方案是确保请求内容类型为application/json,可以使用Postman设置为JSON格式进行调试。若需通过前端ajax发送,需设置content-type为json。
摘要由CSDN通过智能技术生成

springmvc报错如下:

The server refused this request because the request entity is in a format not supported by the requested resource for the requested method.

使用场景:

在后台方法参数上添加@RequestBody时,将请求参数封装成User对象时,需要JSON(application/json)格式解决:在Postman中如下设置即可正常访问,便于调试。

不能使用表单。要使用需要结合ajax设置content-type:json

改为使用postman进行测试,就可以正常访问了

 然后使用json进行传递参数

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值