解决Field error in object ‘user‘ on field ‘name‘: rejected value [Tom]问题
创始人
2024-12-27 09:10:14
0

问题描述

使用postman传递参数,报错400。
在这里插入图片描述

400 Bad Request错误的含义
400 Bad Request错误表示服务器无法理解客户端发送的请求,原因通常是由于客户端发送的请求存在问题。

完整的报错信息如下:

Resolved [org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 1 errorsField error in object 'user' on field 'name': rejected value [Tom]; codes [typeMismatch.user.name,typeMismatch.name,typeMismatch.int,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [user.name,name]; arguments []; default message [name]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'int' for property 'name'; nested exception is java.lang.NumberFormatException: For input string: "Tom"]] 

问题分析

报错400说明客户端传递参数无法正确被服务器接收,报错的重点:

  1. rejected value [Tom]; codes [typeMismatch.user.name,typeMismatch.name,typeMismatch.int,typeMismatch]
  2. Failed to convert property value of type ‘java.lang.String’ to required type ‘int’ for property ‘name’

类型不匹配,name要求int类型,服务器不会认为是自己设置有问题,会判定是客户端传递参数有问题。
回到idea找到代码,果然是int类型。

private int name; 

int 类型是idea联想后直接tab生成出来的,解决方式就是把name换成String类型,重新生成getter和setter,问题解决。

相关内容

热门资讯

第三方技巧!hhpoker软件... 您好,hhpoker可以控制吗这款游戏可以开挂的,确实是有挂的,需要了解加去威信【136704302...
最终!德普之星透视软件免费入口... 最终!德普之星透视软件免费入口官网,aapoker透视脚本,切实存在有挂(今日头条)1、下载好德普之...
日前!模拟器打开hhpoker... 日前!模拟器打开hhpoker,德普辅助软件,总是确实有挂(有挂解惑)1、进入到模拟器打开hhpok...
2026版总结!werplan... 2026版总结!werplan免费挂下载,德州圈脚本,好像真的有挂(有挂技巧)一、werplan免费...
反观!wpk真吗,hhpoke... 反观!wpk真吗,hhpoker破解工具,都是真的有挂(证实有挂)运hhpoker破解工具辅助工具,...
在玩家背景下!hhpoker透... 在玩家背景下!hhpoker透视脚本下载,hhpoker辅助挂,一直确实有挂(有挂详情)1、让任何用...
黑科技辅助挂!fishpoke... 黑科技辅助挂!fishpoker透视底牌,hhpoker有没有作弊挂,一直真的是有挂(真的有挂)1、...
今天上午!aapoker怎么选... 今天上午!aapoker怎么选牌,wepoker私人辅助器,都是是真的有挂(有挂实锤)1、不需要AI...
据目击者称!wpk德州局透视,... 据目击者称!wpk德州局透视,wpk是真的还是假的,真是存在有挂(有挂规律)1、玩家可以在wpk是真...
第三方技巧!xpoker辅助工... 第三方技巧!xpoker辅助工具,wpk俱乐部怎么作弊,一直是有挂(有挂透明挂)1、上手简单,内置详...