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

相关内容

热门资讯

透视数据!智星德州有脚本吗,w... 《透视数据!智星德州有脚本吗,wepoker游戏下载(详细辅助解密教程)》 智星德州有脚本吗软件透明...
wpk辅助工具下载!拱趴大菠萝... wpk辅助工具下载!拱趴大菠萝开挂方法,wepoker底牌透视脚本下载(详细辅助解密教程);wpk辅...
辅助透视!wepoker轻量版... 辅助透视!wepoker轻量版透视,小程序边锋辅助(原来真的是有挂)1、小程序边锋辅助系统规律教程、...
透视了解“aapoker透视软... 透视了解“aapoker透视软件”真是真的是有挂(辅助挂)详细辅助详细教程透视了解“aapoker透...
透视ai代打!hhpoker万... 透视ai代打!hhpoker万能辅助器,聚星ai辅助工具激活码(详细辅助科技教程)1、不需要AI权限...
wepoker透视脚本免费下载... wepoker透视脚本免费下载!wepoker透视最简单三个步骤,wpk透视脚本链接(详细辅助202...
透视神器“wepoker免费透... 透视神器“wepoker免费透视脚本”果然存在有挂(辅助挂)详细辅助攻略教程1)辅助挂:进一步探索辅...
透视美元局!wepoker怎么... 透视美元局!wepoker怎么挂底牌,胡乐安庆辅助工具(真是是真的有挂)胡乐安庆辅助工具软件透明挂微...
透视辅助!wepoker透视,... 透视辅助!wepoker透视,德州之星扫描器(详细辅助教你攻略)关于德州之星扫描器机制的,其中提到了...
wepoker透视脚本安卓!p... wepoker透视脚本安卓!pokermaster脚本,wepoker底牌透视脚本http(详细辅助...