【报错】org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBinding

一、错误

springframework数据绑定错误:
【报错】org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBinding_第1张图片
源码如下:

org.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 1 errors
Field error in object 'position' on field 'professionId': rejected value [{"query_startDate":null,"query_endDate":null}]; codes [typeMismatch.position.professionId,typeMismatch.professionId,typeMismatch.java.lang.Long,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [position.professionId,professionId]; arguments []; default message [professionId]]; default message [Failed to convert property value of type [java.lang.String] to required type [java.lang.Long] for property 'professionId'; nested exception is java.lang.NumberFormatException: For input string: "{"query_startDate":null,"query_endDate":null}"]
    at org.springframework.web.method.annotation.ModelAttributeMethodProcessor.resolveArgument(ModelAttributeMethodProcessor.java:113)
    at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:99)
    at org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:161)
    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:128)
    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:832)
    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:743)
    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85)
    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:961)
    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:895)
    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:967)
    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:858)

二、原因

这里是因为前台传来的参数不对,前来传过来一个id,跟后台的参数professionId不匹配,修改前台传过来参数即可;

你可能感兴趣的:(【报错】,【Spring】)