解决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辅助透视》‌:支持手机实时对战,...
wepoker透视脚本苹果!p... wepoker透视脚本苹果!pokemmo手机版脚本免费,aapoker辅助插件工具(详细辅助黑科技...
透视美元局!智星菠萝可以辅助吗... 透视美元局!智星菠萝可以辅助吗,智星德州插件,介绍教程(都是真的是有挂);一、智星菠萝可以辅助吗软件...
一分钟教会你“九九山城万州版脚... 一分钟教会你“九九山城万州版脚本”wpk辅助器(原先有挂);小薇(透视辅助)致您一封信;亲爱九九山城...
红龙poker作弊指令!wep... 红龙poker作弊指令!wepoker代打辅助,hhpoker透视方法(详细辅助插件教程)1、金币登...
透视ai!wpk辅助器,wpk... 透视ai!wpk辅助器,wpk辅助器,扑克教程(竟然有挂)1、超多福利:超高返利,海量正版游戏,wp...
重大发现“哈狗智能辅助”wep... 重大发现“哈狗智能辅助”wepoker轻量版有透视吗(总是有挂);科技安装教程;136704302。...
wepoker透视脚本免费!佛... 一、wepoker透视脚本免费简介了解软件请加微:136704302wepoker透视脚本免费是一款...
透视软件!wpk脚本辅助器,w... 透视软件!wpk脚本辅助器,wpk透视插件,规律教程(本来是有挂)1、wpk脚本辅助器透视辅助简单,...
一分钟了解“打两圈绝对有辅助”... 一分钟了解“打两圈绝对有辅助”智星德州可以透视吗(最初有挂);亲真的是有正版授权,小编(透视辅助软件...