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

相关内容

热门资讯

每日必看!werplan怎么透... 每日必看!werplan怎么透视,上饶打炸祈福,真是真的有辅助插件(有人有挂)1、完成werplan...
外挂法门!约局吧能不能开挂,x... 外挂法门!约局吧能不能开挂,xpoker辅助器-真是一直都是有辅助神器(哔哩哔哩)1、超多福利:超高...
日前!wepoker有没有挂(... 日前!wepoker有没有挂(透视)竟然是真的辅助软件(有挂猫腻)-哔哩哔哩1、起透看视 wepok...
一分钟带你了解!wepoker... 一分钟带你了解!wepoker辅助器免费,凑一桌开挂游戏辅助,原来是真的有辅助插件(有挂教学)1、凑...
外挂阶段!云扑克有透视吗,德州... 外挂阶段!云扑克有透视吗,德州私人局脚本-果然真的是有辅助脚本(哔哩哔哩)暗藏猫腻,小编详细说明德州...
针对!德州hhpoker是真的... 针对!德州hhpoker是真的吗(透视)切实有辅助神器(有挂详细)-哔哩哔哩德州hhpoker是真的...
教程攻略!wpk模拟器多开,雀... 教程攻略!wpk模拟器多开,雀神麻雀充运势有用吗,一直真的是有辅助辅助(有挂秘诀)1、雀神麻雀充运势...
外挂窍要!哈糖大菠萝软件下载,... 外挂窍要!哈糖大菠萝软件下载,约局吧德州可以透视吗-真是一直都是有辅助攻略(哔哩哔哩)1、操作简单,...
截至发稿!hhpoker辅助软... 截至发稿!hhpoker辅助软件下载(透视)本来是有辅助下载(有挂方法)-哔哩哔哩1、金币登录送、破...
玩家必备教程!wejoker辅... 玩家必备教程!wejoker辅助器怎么卖,越乡游义乌辅助器微信,好像真的是有辅助教程(揭秘有挂)越乡...