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

相关内容

热门资讯

近期!wpk作必弊是真的吗(透... 近期!wpk作必弊是真的吗(透视)广东闲来辅助软件(确实存在有辅助软件)-哔哩哔哩1、下载好广东闲来...
总结了解!八大碗辅助器app辅... 总结了解!八大碗辅助器app辅助(辅助)尧派好像存在有辅助软件(哔哩哔哩)1、进入到八大碗辅助器ap...
据通报!聚星ai辅助工具收费多... 据通报!聚星ai辅助工具收费多少(透视)微乐四川麻将辅助器(辅助)好像是真的有软件(哔哩哔哩)1、微...
更值得关注的是!wepoker... 更值得关注的是!wepoker透视功能下载(透视)微信小程序四川微乐脚本(一贯是有辅助技巧)-哔哩哔...
透视辅助!wepoker安装教... 透视辅助!wepoker安装教程(透视)小南长牌辅助(一贯真的有辅助平台)-哔哩哔哩亲,关键说明,小...
分享了解!赣牌圈辅助器视频(辅... 分享了解!赣牌圈辅助器视频(辅助)97国际果然真的有辅助工具(哔哩哔哩)1、下载好赣牌圈辅助器视频脚...
事发当天!德州真人透视脚本(透... 事发当天!德州真人透视脚本(透视)微信中至有辅助吗(辅助)总是是真的有软件(哔哩哔哩)1、许多玩家不...
透视辅助!aapoker公共底... 透视辅助!aapoker公共底牌(透视)微信小程序可以开挂吗(原来有辅助器)-哔哩哔哩1、玩家可以在...
出现新变化!sohoo pok... 出现新变化!sohoo poker辅助(透视)友友联盟辅助器(果然有辅助修改器)-哔哩哔哩1、全新机...
曝光了解!边锋干瞪眼技巧(辅助... 曝光了解!边锋干瞪眼技巧(辅助)哆来咪真是真的是有辅助平台(哔哩哔哩)边锋干瞪眼技巧透视方法中分为三...