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

相关内容

热门资讯

总算了解开挂脚本!wepoke... 总算了解开挂脚本!wepoker辅助功能开透视工具,总是存在有挂(了解有挂)wepoker透视方法中...
一分钟秒懂透视挂技巧!AAPo... 一分钟秒懂透视挂技巧!AAPoKer辅助功能开透视工具,真是真的有挂(有挂透视)1)AAPoKer免...
技术分享透视挂攻略!智星菠萝德... 技术分享透视挂攻略!智星菠萝德州辅助功能开透视工具,果然有挂(有挂方略)1、超多福利:超高返利,海量...
总算了解透视挂教程!AAPoK... 总算了解透视挂教程!AAPoKer辅助功能开透视工具,都是真的有挂(证实有挂)运AAPoKer辅助工...
新手必备开挂教程!aapoke... 新手必备开挂教程!aapoker辅助功能开透视工具,真是存在有挂(有挂解惑)1、首先打开aapoke...
最新技巧透视挂脚本!微扑克辅助... 最新技巧透视挂脚本!微扑克辅助功能开透视工具,其实是有挂(有挂猫腻)1、金币登录送、破产送、升级送、...
盘点几款透视挂工具!AAPoK... 盘点几款透视挂工具!AAPoKer辅助功能开透视工具,原来有挂(有挂技巧)1、首先打开AAPoKer...
今日焦点开挂方法!德扑圈辅助功... 今日焦点开挂方法!德扑圈辅助功能开透视工具,总是是真的有挂(有挂辅助)该软件可以轻松地帮助玩家将德扑...
发现玩家辅助软件!智星德州扑克... 发现玩家辅助软件!智星德州扑克辅助功能开透视工具,切实存在有挂(真的有挂)1、超多福利:超高返利,海...
交流学习经验开挂工具!WPK辅... 交流学习经验开挂工具!WPK辅助功能开透视工具,一直真的是有挂(有挂辅助)WPK透视方法中分为三种模...