当前位置: 首页 > news >正文

HTTP Error 400 Bad request 问题分析解决

在这里插入图片描述

文章目录

      • 1.问题描述:
      • 2.异常信息如下:
      • 3.分析异常信息:
      • 4.总结:


1.问题描述:

前端保存老是报错HTTP ERROR 400 Bad Request。经过异常分析得出是前端传参导致的后端框架的验证拦截,包的错误。

2.异常信息如下:


{"timestamp":1545873831082,"status":400,"error":"Bad Request","exception":"org.springframework.validation.BindException","errors":[{"codes":["typeMismatch.capitalInvestmentParam.investmentEnsureMoney","typeMismatch.investmentEnsureMoney","typeMismatch.java.math.BigDecimal","typeMismatch"],"arguments":[{"codes":["capitalInvestmentParam.investmentEnsureMoney","investmentEnsureMoney"],"arguments":null,"defaultMessage":"investmentEnsureMoney","code":"investmentEnsureMoney"}],"defaultMessage":"Failed to convert property value of type 'java.lang.String' to required type 'java.math.BigDecimal' for property 'investmentEnsureMoney'; nested exception is java.lang.NumberFormatException","objectName":"capitalInvestmentParam","field":"investmentEnsureMoney","rejectedValue":"null","bindingFailure":true,"code":"typeMismatch"},{"codes":["typeMismatch.capitalInvestmentParam.investmentEnsureMoneyInterest","typeMismatch.investmentEnsureMoneyInterest","typeMismatch.java.math.BigDecimal","typeMismatch"],"arguments":[{"codes":["capitalInvestmentParam.investmentEnsureMoneyInterest","investmentEnsureMoneyInterest"],"arguments":null,"defaultMessage":"investmentEnsureMoneyInterest","code":"investmentEnsureMoneyInterest"}],"defaultMessage":"Failed to convert property value of type 'java.lang.String' to required type 'java.math.BigDecimal' for property 'investmentEnsureMoneyInterest'; nested exception is java.lang.NumberFormatException","objectName":"capitalInvestmentParam","field":"investmentEnsureMoneyInterest","rejectedValue":"null","bindingFailure":true,"code":"typeMismatch"}],"message":"Validation failed for object='capitalInvestmentParam'. Error count: 2","path":"/rayProjectCapitalInvestment/insertStockPowerInvestment"}

3.分析异常信息:

Failed to convert property value of type ‘java.lang.String’ to required type ‘java.math.BigDecimal’ for property ‘investmentEnsureMoneyInterest’; nested exception is java.lang.NumberFormatException

看一下前端传入的参数如下图:
image.png
image.png
前端的参数应该是金额要么是空值,结果传输的时候传一个null,后台接收的时候是用bigDecimal 参数类型导致参数异常,报的400错误问题。

4.总结:

经过分析得出400错误code:数据框架的验证拦截前端传入的参数异常,参数类型异常,一般情况下出现400,都是前端传入的参数异常。

http://www.lqws.cn/news/94555.html

相关文章:

  • 【前端并发请求控制:必要性与实现策略】
  • 如何进行页面前端监控
  • 手摸手还原vue3中reactive的get陷阱以及receiver的作用
  • SpringBoot3.2新特性:JdbcClient
  • web攻防之SSTI 注入漏洞
  • Windows 下部署 SUNA 项目:虚拟环境尝试与最终方案
  • 【从0-1的HTML】第2篇:HTML标签
  • Double/Debiased Machine Learning
  • 从仿射矩阵得到旋转量平移量缩放量
  • 【氮化镓】GaN HMETs器件物理失效分析进展
  • 【Java Web】7.事务管理AOP
  • 下载并运行自制RAG框架
  • PyTorch——线性层及其他层介绍(6)
  • Apache Iceberg 如何实现分布式 ACID 事务:深度解析大数据时代的可靠数据管理
  • Java面试八股--07-项目篇
  • 极智项目 | 基于PyQT+Whisper实现的语音识别软件设计
  • 从一堆数字里长出一棵树:中序 + 后序构建二叉树的递归密码
  • 懒猫微服进阶心得(五):使用懒猫微服做Ventoy启动盘
  • ArrayList 类
  • Vue混入
  • Nginx 的配置文件
  • OpenCV 滑动条调整图像亮度
  • [yolov11改进系列]基于yolov11使用FasterNet替换backbone用于轻量化网络的python源码+训练源码
  • 谷歌地图苹果版v6.138.2 - 前端工具导航
  • DrissionPage 性能优化实战指南:让网页自动化效率飞升
  • MySQL 8 完整安装指南(Ubuntu 22.04)
  • 【R语言编程绘图-mlbench】
  • 实验设计与分析(第6版,Montgomery著,傅珏生译) 第9章三水平和混合水平析因设计与分式析因设计9.5节思考题9.1 R语言解题
  • 实验设计与分析(第6版,Montgomery著,傅珏生译) 第10章拟合回归模型10.9节思考题10.1 R语言解题
  • R语言使用随机过采样(Random Oversampling)平衡数据集