org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 1 errors

最近在项目中发现如下异常:

六月 25, 2015 5:58:34 下午 org.apache.catalina.core.StandardWrapperValve invoke
严重: Servlet.service() for servlet springMVC threw exception
org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 1 errors
Field error in object ‘recordFileLostMonitorVo‘ on field ‘checkResult‘: rejected value []; codes [methodInvocation.recordFileLostMonitorVo.checkResult,methodInvocation.checkResult,methodInvocation.long,methodInvocation]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [recordFileLostMonitorVo.checkResult,checkResult]; arguments []; default message [checkResult]]; default message [Property ‘checkResult‘ threw exception; nested exception is java.lang.IllegalArgumentException]
 at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.doBind(HandlerMethodInvoker.java:810)
 at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.resolveHandlerArguments(HandlerMethodInvoker.java:359)
 at org.springframework.web.bind.annotation.support.HandlerMethodInvoker.invokeHandlerMethod(HandlerMethodInvoker.java:171)
 at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.invokeHandlerMethod(AnnotationMethodHandlerAdapter.java:436)
 at org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter.handle(AnnotationMethodHandlerAdapter.java:424)
 at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:790)
 at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)
 at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:669)
 at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:585)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
 at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 at com.speed.base.filter.Log4jUserFilter.doFilter(Log4jUserFilter.java:29)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
 at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
 at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
 at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
 at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
 at java.lang.Thread.run(Thread.java:722)

跟踪字段发现原来是下拉框<option>中参数赋值错误导致,详见如下:

原来的html:

<select id="checkResult" name="checkResult">
  <option value="">全部</option>
     <option value="0">不存在</option>
     <option value="1">已存在</option>

</select>

后台用的是mybatis,而对应的vo中定义的checkResult是long类型,所以导致把空字符串赋值给long类型的checkResult时发生了如上的异常,修改如下:

<select id="checkResult" name="checkResult">
  <option value="-1">全部</option>
     <option value="0">不存在</option>
     <option value="1">已存在</option>

</select>

时间: 2024-10-14 06:07:35

org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 1 errors的相关文章

rest-assured之Schema validation(包括JSON Schema validation及Xml Schema validation)

rest-assured从2.1.0版本开始支持  Schema 验证,包括JSON Schema validation及Xml Schema validation.我们之前断言响应体都是一个一个字段来进行断言,这样如果断言的字段比较多的话就非常的麻烦,为了解决这个问题,我们可以使用schema文件来进行响应体的断言,schema文件可以断言整个response . 1.JSON Schema validation 例如:在classpath下面放置以下的schema文件,products-sc

Spring MVC,HTTP Status 400 ,jQuery

一.先看下4xx错误的说明 [转载] http status 400,http 400,400 错误 [参考] status code 400, Bad Request (§10.4.1) 4 请求失败4xx 4xx应答定义了特定服务器响应的请求失败的情况.客户端不应当在不更改请求的情况下重新尝试同一个请求.(例如,增加合适的认证信息).不过,同一个请求交给不同服务器也许就会成功. 4.1 400 Bad Request 请求中的语法错误.Reason-Phrase应当标志这个详细的语法错误,比

前台日期字符串 提交到后台 组装entity失败原因

错误信息 WARN - Resolved exception caused by Handler execution: org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 1 errorsField error in object 'inStorage' on field 'orderTime': rejected value [2017-0

SpringMVC在使用过程中的错误

HTTP Status 500 - Request processing failed; nested exception is org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 3 errors org.springframework.web.util.NestedServletException: Request processing

表单提交验证报错

[org.jeecgframework.core.common.exception.GlobalExceptionResolver]全局处理异常捕获:org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 1 errorsField error in object 'goodsEntity' on field 'id': rejected val

JodaTime library not available - @DateTimeFormat not supported

使用spring的@DateTimeFormat来格式化Date类型时,报错: org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 1 errorsField error in object 'modelInfoExample' on field 'birthday': rejected value [2014-12-09]; codes [

Spring MVC与表单日期提交的问题

Spring MVC与表单日期提交的问题 spring mvc 本身并不提供日期类型的解析器,需要手工绑定, 否则会出现非法参数异常. org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [java.util.Date]: Constructor threw exception; nested exception is java.lang.IllegalArgumentExc

Spring MVC 学习

URL请求处理流程: graph LR id1(URL处理方法映射)-->id2(参数解析) id2-->id3(执行方法) id3-->id4(响应请求) 1. URL处理方法映射 1.1 Controller 页面控制器,内部可以包含处理具体请求的方法(@RequestMapping). @Controller:返回视图,如jsp或者html文件: @RestController:返回JSON,如字符串,或者数组: 1.2 @RequestMapping 作用:指定url请求的处理方

spring mvc绑定参数之日期类型转换

问题复现步骤: 1.提交表单,参数为: 2.接收参数类型为product实体类,如下 3.错误日志如下: org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 1 errorsField error in object 'product' on field 'departureTime': rejected value [2020-02-10