提交表单时,字段有的没有值,springboot 会报错。

org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 4 errors
Field error in object 'stone' on field 'stone_purchdate': rejected value [2018-05-11T16:00:00.000+0000]; codes [typeMismatch.stone.stone_purchdate,typeMismatch.stone_purchdate,typeMismatch.java.util.Date,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [stone.stone_purchdate,stone_purchdate]; arguments []; default message [stone_purchdate]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'java.util.Date' for property 'stone_purchdate'; nested exception is java.lang.IllegalArgumentException: Could not parse date: Unparseable date: "2018-05-11T16:00:00.000+0000"]
Field error in object 'stone' on field 'stone_substoPramt': rejected value []; codes [typeMismatch.stone.stone_substoPramt,typeMismatch.stone_substoPramt,typeMismatch.double,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [stone.stone_substoPramt,stone_substoPramt]; arguments []; default message [stone_substoPramt]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'double' for property 'stone_substoPramt'; nested exception is java.lang.NumberFormatException: empty String]
Field error in object 'stone' on field 'stone_substoPrperct': rejected value []; codes [typeMismatch.stone.stone_substoPrperct,typeMismatch.stone_substoPrperct,typeMismatch.double,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [stone.stone_substoPrperct,stone_substoPrperct]; arguments []; default message [stone_substoPrperct]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'double' for property 'stone_substoPrperct'; nested exception is java.lang.NumberFormatException: empty String]
Field error in object 'stone' on field 'stone_substoWgt': rejected value []; codes [typeMismatch.stone.stone_substoWgt,typeMismatch.stone_substoWgt,typeMismatch.double,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [stone.stone_substoWgt,stone_substoWgt]; arguments []; default message [stone_substoWgt]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'double' for property 'stone_substoWgt'; nested exception is java.lang.NumberFormatException: empty String]
at org.springframework.web.method.annotation.ModelAttributeMethodProcessor.resolveArgument(ModelAttributeMethodProcessor.java:157) ~[spring-web-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:124) ~[spring-web-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:161) [spring-web-5.0.6.RELEASE.jar:5.0.6.RELEASE]

解决方法:

参数里加上 BindingResult 即可

org.springframework.validation.BindingResult

General interface that represents binding results. Extends the interface for error registration capabilities, allowing for a Validator to be applied, and adds binding-specific analysis and model building.

Serves as result holder for a DataBinder, obtained via the DataBinder.getBindingResult() method. BindingResult implementations can also be used directly, for example to invoke a Validator on it (e.g. as part of a unit test).

Since:
2.0
Author:
Juergen Hoeller
See Also:
DataBinder
Errors
Validator
BeanPropertyBindingResult
DirectFieldBindingResult
MapBindingResult

转载于:https://www.cnblogs.com/lick468/p/9131911.html

spring boot 开发 提交form表单出错相关推荐

  1. 使用ajax提交form表单,包括ajax文件上传 转http://www.cnblogs.com/zhuxiaojie/p/4783939.html...

    使用ajax提交form表单,包括ajax文件上传 前言 使用ajax请求数据,很多人都会,比如说: $.post(path,{data:data},function(data){... },&quo ...

  2. 学习日志day45(2021-09-09)(1、有道翻译API使用json格式数据 2、JSONP 3、Ajax提交form表单 4、Web Uploader)

    学习内容:学习JavaWeb(Day45) 1.有道翻译API使用json格式数据 2.JSONP 3.Ajax提交form表单 4.Web Uploader 1.有道翻译API使用json格式数据 ...

  3. ajax 表单提交传文件,Ajax提交Form表单及文件上传

    刚刚申请下来的博客,写得第一篇.有点小激动,本人以前是一名工业3D设计师突然有些变故做上了JavaWeb开发: 前几天,发现了一些小问题.我在写后台管理页面时,需要上传一张图片.于是我就用很普通的Fo ...

  4. 在微信小程序中提交form表单

    怎么在微信小程序中提交form表单 发布时间:2021-04-07 16:26:31 来源:亿速云 阅读:1229 作者:Leah 栏目:web开发 活动:亿速云新用户活动,各类服务器大降价,满足绝大 ...

  5. form表单提交以及用Jquery实现ajax提交form表单

    在form标签中添加Action(提交的地址)和method(post),且有一个submit按钮(<input type='submit'>)就可以进行数据的提交,每一个input标签都 ...

  6. js异步提交form表单的解决方案

    1.定义异步提交表单的方法 (通用方法) /*** 异步提交form表单* @param options {form:form表单元素,success:执行成功后处理函数}* <span sty ...

  7. Jquery通过Ajax方式来提交Form表单

    今天刚好看到Jquery的ajax提交数据到服务器的方法,原文是: 保存数据到服务器,成功时显示信息. jQuery 代码: $.ajax({type: "POST",url: & ...

  8. html form通过ajax提交表单提交数据,Jquery通过Ajax方式来提交Form表单的具体实现

    今天刚好看到Jquery的ajax提交数据到服务器的方法,原文是: 保存数据到服务器,成功时显示信息. jQuery 代码: $.ajax({ type: "POST", url: ...

  9. js 提交form表单,js更改form表单的action属性

    2019独角兽企业重金招聘Python工程师标准>>> js 提交form表单 <s:form id="formID1" action="favo ...

最新文章

  1. OpenGL画矩形,三角形,点(第一个图形学的小程序)
  2. 哪些医药企业使用SAP系统呢?
  3. java的简单工厂模式_java设计模式之简单工厂模式
  4. 8.19noip模拟题
  5. C++之泛型编程(模板)
  6. git github gitlib gitlab
  7. centos7将网卡名字改成eth样式
  8. Nginx代理连接Redis失败
  9. 【华为云技术分享】玩转华为物联网IoTDA服务系列三-自动售货机销售分析场景示例
  10. idea mysql 逆向生成,IDEA mybatis-generator逆向工程生成代码
  11. 温故10个经典排序算法(Java版)
  12. Linux内核网络编程
  13. 《回话的技术》阅读笔记
  14. 2019年1月起Oracle要对JDK8就要收费了!
  15. [黑科技]DNS隧道-绕过wifi热点登陆免费上网
  16. 如何给Word重新排页码
  17. 魔力 java下载安装,UBNT EdgeMAX EdgeRouter ERPoE-5 POE+ UAP-AC-PRO开箱及安装调试
  18. 书1_JavaEE概念/项目_22/5/29
  19. 【云和恩墨大讲堂】赴春天第一场约会,深圳等你
  20. Leaflet创建,tileLayer,marker,面的绘制

热门文章

  1. 用系统某一用户的的身份运行某一命令
  2. 使用Xcode和Instruments调试解决iOS内存泄露【转】
  3. oracle基础之工具系列(持续更新中,,)
  4. 请大家访问另一个我的博客!
  5. 一个自带简易数据集的模拟线性分类器matlab代码——实验训练
  6. 机器学习知识点(六)增广矩阵求解拉格朗日乘子法的Java实现
  7. Java字节码进制转换
  8. tensorflow sobel算子实现
  9. 计算机二级考试vb内容,计算机二级考试VB重点内容.doc
  10. 罗斯蒙特电磁流量计8723说明书_罗斯蒙特8732EM电磁流量计变送器如何接线!