解决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,问题解决。

相关内容

热门资讯

最新技巧!wepoker永久免... 最新技巧!wepoker永久免费脚本,友友联盟辅助脚本,一直真的有辅助下载(有挂细节)1、实时友友联...
重大来袭!wepokerh5破... 重大来袭!wepokerh5破解,广西老友玩助手,一直真的有辅助辅助(存在有挂)广西老友玩助手脚本下...
一分钟揭秘!wepoker透视... 您好,决战卡五星辅助修改器这款游戏可以开挂的,确实是有挂的,需要了解加去威信【485275054】很...
玩家必看教程!WePoKer辅... 玩家必看教程!WePoKer辅助器,兴动助手脚本有辅助,竟然真的有辅助神器(有挂方法)1、兴动助手脚...
一分钟揭秘!wepoker代打... 一分钟揭秘!wepoker代打辅助机器人,欢乐联盟免费辅助,本来存在有辅助辅助(有挂详情)欢乐联盟免...
总算了解!wepoker破解工... 总算了解!wepoker破解工具,人海大厅反杀,本来存在有辅助下载(有挂攻略)1、每一步都需要思考,...
教学盘点!大菠萝辅助器,宁夏划... 教学盘点!大菠萝辅助器,宁夏划水辅助,一贯有辅助开挂(果真有挂)大菠萝辅助器脚本下载中分为三种模型:...
玩家交流!wepoker手机插... 玩家交流!wepoker手机插件,宁波同乡游辅助下载,竟然真的是有辅助工具(有挂教程)1)宁波同乡游...
一分钟了解!wepoker俱乐... 一分钟了解!wepoker俱乐部辅助,九游辅助辅助在哪里,本来真的是有辅助工具(有挂秘诀)1、全新机...
分享个大家!wepoker永久... 分享个大家!wepoker永久免费脚本,陕西辅助,本来真的是有辅助脚本(有挂攻略)1、陕西辅助模拟器...