国产成人精品亚洲777人妖,欧美日韩精品一区视频,最新亚洲国产,国产乱码精品一区二区亚洲

您的位置:首頁(yè)技術(shù)文章
文章詳情頁(yè)

javascript - java日期數(shù)據(jù)前后臺(tái)傳遞

瀏覽:165日期:2023-09-11 09:24:26

問(wèn)題描述

是這樣的,我前臺(tái)用了ant-design的控件傳入日期類(lèi)型“2017-5”,后臺(tái)我用LocalDate類(lèi)型接收,結(jié)果報(bào)錯(cuò)了

Field error in object ’arrearsStatisticsQueryInfo’ on field ’statisticalMonth’: rejected value [2017-05]; codes [typeMismatch.arrearsStatisticsQueryInfo.statisticalMonth,typeMismatch.statisticalMonth,typeMismatch.java.time.LocalDate,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [arrearsStatisticsQueryInfo.statisticalMonth,statisticalMonth]; arguments []; default message [statisticalMonth]]; default message [Failed to convert property value of type [java.lang.String] to required type [java.time.LocalDate] for property ’statisticalMonth’; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type [java.lang.String] to type [java.time.LocalDate] for value ’2017-05’; nested exception is java.time.format.DateTimeParseException: Text ’2017-05’ could not be parsed at index 2]-/api/order/arrearsStatisticsorg.springframework.validation.BindException: org.springframework.validation.BeanPropertyBindingResult: 1 errorsField error in object ’arrearsStatisticsQueryInfo’ on field ’statisticalMonth’: rejected value [2017-05]; codes [typeMismatch.arrearsStatisticsQueryInfo.statisticalMonth,typeMismatch.statisticalMonth,typeMismatch.java.time.LocalDate,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [arrearsStatisticsQueryInfo.statisticalMonth,statisticalMonth]; arguments []; default message [statisticalMonth]]; default message [Failed to convert property value of type [java.lang.String] to required type [java.time.LocalDate] for property ’statisticalMonth’; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type [java.lang.String] to type [java.time.LocalDate] for value ’2017-05’; nested exception is java.time.format.DateTimeParseException: Text ’2017-05’ could not be parsed at index 2] at org.springframework.web.method.annotation.ModelAttributeMethodProcessor.resolveArgument(ModelAttributeMethodProcessor.java:113) ~[spring-web-4.2.4.RELEASE.jar:4.2.4.RELEASE] at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:78) ~[spring-web-4.2.4.RELEASE.jar:4.2.4.RELEASE] at org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:162) ~[spring-web-4.2.4.RELEASE.jar:4.2.4.RELEASE] at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:129) ~[spring-web-4.2.4.RELEASE.jar:4.2.4.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:110) ~[spring-webmvc-4.2.4.RELEASE.jar:4.2.4.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:814) ~[spring-webmvc-4.2.4.RELEASE.jar:4.2.4.RELEASE] at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:737) ~[spring-webmvc-4.2.4.RELEASE.jar:4.2.4.RELEASE] at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:85) ~[spring-webmvc-4.2.4.RELEASE.jar:4.2.4.RELEASE] at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:959) ~[spring-webmvc-4.2.4.RELEASE.jar:4.2.4.RELEASE] at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:893) ~[spring-webmvc-4.2.4.RELEASE.jar:4.2.4.RELEASE] at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:969) [spring-webmvc-4.2.4.RELEASE.jar:4.2.4.RELEASE] at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:860) [spring-webmvc-4.2.4.RELEASE.jar:4.2.4.RELEASE] at javax.servlet.http.HttpServlet.service(HttpServlet.java:622) [tomcat-embed-core-8.0.30.jar:8.0.30] at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:845) [spring-webmvc-4.2.4.RELEASE.jar:4.2.4.RELEASE] at javax.servlet.http.HttpServlet.service(HttpServlet.java:729) [tomcat-embed-core-8.0.30.jar:8.0.30]

我的后臺(tái)怎么樣才能接收呢?其實(shí)得到2017-5-1這一天也可以

問(wèn)題解答

回答1:

用string接收然后轉(zhuǎn)成時(shí)間格式

回答2:

謝邀, 看日志應(yīng)該是String轉(zhuǎn)LocalDate類(lèi)型沒(méi)有指定格式的錯(cuò)誤

在statisticalMonth這個(gè)field上加上org.springframework.format.annotation.@DateTimeFormat

回答3:

時(shí)間數(shù)據(jù)序列化比較麻煩,用Date對(duì)象接收也行,需要做一些配置,用string或long比較省心!

標(biāo)簽: JavaScript
相關(guān)文章:
主站蜘蛛池模板: 无棣县| 将乐县| 潼南县| 育儿| 林甸县| 银川市| 中阳县| 广西| 西吉县| 茌平县| 焉耆| 南京市| 定州市| 湄潭县| 河东区| 中方县| 蓬溪县| 子洲县| 汉沽区| 平遥县| 恩施市| 行唐县| 噶尔县| 石河子市| 南靖县| 宜丰县| 金寨县| 本溪市| 斗六市| 西畴县| 宜兴市| 两当县| 九江县| 克拉玛依市| 和顺县| 嘉定区| 禹城市| 遂平县| 宜城市| 和林格尔县| 临桂县|