Requestbody接受参数的时候发生了400, 但是前端看数据并没有问题, 可以用json工具解析, 而且一样的数据时好时坏

二小欧巴
  • 122

后端异常信息:

2021/7/16 下午2:21:372021-07-16 14:21:37.286 ERROR 1 --- [nio-8222-exec-3] c.f.b.config.BudgetExceptionHandler      : 请求状态码: [400], 请求异常信息: JSON parse error: Unexpected end-of-input in VALUE_STRING; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Unexpected end-of-input in VALUE_STRING
2021/7/16 下午2:21:37 at [Source: (PushbackInputStream); line: 1, column: 1487] (through reference chain: com.faujor.budget.dataobject.BudgetMaterialCost["customerType"])
2021/7/16 下午2:21:37
2021/7/16 下午2:21:37org.springframework.http.converter.HttpMessageNotReadableException: JSON parse error: Unexpected end-of-input in VALUE_STRING; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Unexpected end-of-input in VALUE_STRING
2021/7/16 下午2:21:37 at [Source: (PushbackInputStream); line: 1, column: 1487] (through reference chain: com.faujor.budget.dataobject.BudgetMaterialCost["customerType"])
2021/7/16 下午2:21:37    at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.readJavaType(AbstractJackson2HttpMessageConverter.java:245) ~[spring-web-5.1.3.RELEASE.jar!/:5.1.3.RELEASE]
2021/7/16 下午2:21:37    at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.read(AbstractJackson2HttpMessageConverter.java:227) ~[spring-web-5.1.3.RELEASE.jar!/:5.1.3.RELEASE]
2021/7/16 下午2:21:37    at org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodArgumentResolver.readWithMessageConverters(AbstractMessageConverterMethodArgumentResolver.java:204) ~[spring-webmvc-5.1.3.RELEASE.jar!/:5.1.3.RELEASE]
2021/7/16 下午2:21:37    at org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.readWithMessageConverters(RequestResponseBodyMethodProcessor.java:157) ~[spring-webmvc-5.1.3.RELEASE.jar!/:5.1.3.RELEASE]
2021/7/16 下午2:21:37    at org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.resolveArgument(RequestResponseBodyMethodProcessor.java:130) ~[spring-webmvc-5.1.3.RELEASE.jar!/:5.1.3.RELEASE]
2021/7/16 下午2:21:37    at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:126) ~[spring-web-5.1.3.RELEASE.jar!/:5.1.3.RELEASE]
2021/7/16 下午2:21:37    at org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:166) ~[spring-web-5.1.3.RELEASE.jar!/:5.1.3.RELEASE]
2021/7/16 下午2:21:37    at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:134) ~[spring-web-5.1.3.RELEASE.jar!/:5.1.3.RELEASE]
2021/7/16 下午2:21:37    at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102) ~[spring-webmvc-5.1.3.RELEASE.jar!/:5.1.3.RELEASE]
2021/7/16 下午2:21:37    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895) ~[spring-webmvc-5.1.3.RELEASE.jar!/:5.1.3.RELEASE]
2021/7/16 下午2:21:37    at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:800) ~[spring-webmvc-5.1.3.RELEASE.jar!/:5.1.3.RELEASE]
2021/7/16 下午2:21:37    at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.1.3.RELEASE.jar!/:5.1.3.RELEASE]
2021/7/16 下午2:21:37    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1038) ~[spring-webmvc-5.1.3.RELEASE.jar!/:5.1.3.RELEASE]
2021/7/16 下午2:21:37    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942) ~[spring-webmvc-5.1.3.RELEASE.jar!/:5.1.3.RELEASE]
2021/7/16 下午2:21:37    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1005) [spring-webmvc-5.1.3.RELEASE.jar!/:5.1.3.RELEASE]
2021/7/16 下午2:21:37    at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:908) [spring-webmvc-5.1.3.RELEASE.jar!/:5.1.3.RELEASE]
2021/7/16 下午2:21:37    at javax.servlet.http.HttpServlet.service(HttpServlet.java:660) [tomcat-embed-core-9.0.13.jar!/:9.0.13]
2021/7/16 下午2:21:37    at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:882) [spring-webmvc-5.1.3.RELEASE.jar!/:5.1.3.RELEASE]
2021/7/16 下午2:21:37    at javax.servlet.http.HttpServlet.service(HttpServlet.java:741) [tomcat-embed-core-9.0.13.jar!/:9.0.13]
2021/7/16 下午2:21:37    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231) [tomcat-embed-core-9.0.13.jar!/:9.0.13]
2021/7/16 下午2:21:37    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [tomcat-embed-core-9.0.13.jar!/:9.0.13]
2021/7/16 下午2:21:37    at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) [tomcat-embed-websocket-9.0.13.jar!/:9.0.13]
2021/7/16 下午2:21:37    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [tomcat-embed-core-9.0.13.jar!/:9.0.13]
2021/7/16 下午2:21:37    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [tomcat-embed-core-9.0.13.jar!/:9.0.13]
2021/7/16 下午2:21:37    at org.springframework.boot.actuate.web.trace.servlet.HttpTraceFilter.doFilterInternal(HttpTraceFilter.java:90) [spring-boot-actuator-2.1.1.RELEASE.jar!/:2.1.1.RELEASE]
2021/7/16 下午2:21:37    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-5.1.3.RELEASE.jar!/:5.1.3.RELEASE]
2021/7/16 下午2:21:37    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [tomcat-embed-core-9.0.13.jar!/:9.0.13]
2021/7/16 下午2:21:37    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [tomcat-embed-core-9.0.13.jar!/:9.0.13]
2021/7/16 下午2:21:37    at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:99) [spring-web-5.1.3.RELEASE.jar!/:5.1.3.RELEASE]
2021/7/16 下午2:21:37    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-5.1.3.RELEASE.jar!/:5.1.3.RELEASE]
2021/7/16 下午2:21:37    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [tomcat-embed-core-9.0.13.jar!/:9.0.13]
2021/7/16 下午2:21:37    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [tomcat-embed-core-9.0.13.jar!/:9.0.13]
2021/7/16 下午2:21:37    at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:92) [spring-web-5.1.3.RELEASE.jar!/:5.1.3.RELEASE]
2021/7/16 下午2:21:37    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-5.1.3.RELEASE.jar!/:5.1.3.RELEASE]
2021/7/16 下午2:21:37    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [tomcat-embed-core-9.0.13.jar!/:9.0.13]
2021/7/16 下午2:21:37    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [tomcat-embed-core-9.0.13.jar!/:9.0.13]
2021/7/16 下午2:21:37    at org.springframework.web.filter.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:93) [spring-web-5.1.3.RELEASE.jar!/:5.1.3.RELEASE]
2021/7/16 下午2:21:37    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-5.1.3.RELEASE.jar!/:5.1.3.RELEASE]
2021/7/16 下午2:21:37    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [tomcat-embed-core-9.0.13.jar!/:9.0.13]
2021/7/16 下午2:21:37    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [tomcat-embed-core-9.0.13.jar!/:9.0.13]
2021/7/16 下午2:21:37    at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.filterAndRecordMetrics(WebMvcMetricsFilter.java:117) [spring-boot-actuator-2.1.1.RELEASE.jar!/:2.1.1.RELEASE]
2021/7/16 下午2:21:37    at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:106) [spring-boot-actuator-2.1.1.RELEASE.jar!/:2.1.1.RELEASE]
2021/7/16 下午2:21:37    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-5.1.3.RELEASE.jar!/:5.1.3.RELEASE]
2021/7/16 下午2:21:37    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [tomcat-embed-core-9.0.13.jar!/:9.0.13]
2021/7/16 下午2:21:37    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [tomcat-embed-core-9.0.13.jar!/:9.0.13]
2021/7/16 下午2:21:37    at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200) [spring-web-5.1.3.RELEASE.jar!/:5.1.3.RELEASE]
2021/7/16 下午2:21:37    at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107) [spring-web-5.1.3.RELEASE.jar!/:5.1.3.RELEASE]
2021/7/16 下午2:21:37    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) [tomcat-embed-core-9.0.13.jar!/:9.0.13]
2021/7/16 下午2:21:37    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) [tomcat-embed-core-9.0.13.jar!/:9.0.13]
2021/7/16 下午2:21:37    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:199) [tomcat-embed-core-9.0.13.jar!/:9.0.13]
2021/7/16 下午2:21:37    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) [tomcat-embed-core-9.0.13.jar!/:9.0.13]
2021/7/16 下午2:21:37    at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:490) [tomcat-embed-core-9.0.13.jar!/:9.0.13]
2021/7/16 下午2:21:37    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139) [tomcat-embed-core-9.0.13.jar!/:9.0.13]
2021/7/16 下午2:21:37    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) [tomcat-embed-core-9.0.13.jar!/:9.0.13]
2021/7/16 下午2:21:37    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74) [tomcat-embed-core-9.0.13.jar!/:9.0.13]
2021/7/16 下午2:21:37    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) [tomcat-embed-core-9.0.13.jar!/:9.0.13]
2021/7/16 下午2:21:37    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408) [tomcat-embed-core-9.0.13.jar!/:9.0.13]
2021/7/16 下午2:21:37    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) [tomcat-embed-core-9.0.13.jar!/:9.0.13]
2021/7/16 下午2:21:37    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:791) [tomcat-embed-core-9.0.13.jar!/:9.0.13]
2021/7/16 下午2:21:37    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1417) [tomcat-embed-core-9.0.13.jar!/:9.0.13]
2021/7/16 下午2:21:37    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-9.0.13.jar!/:9.0.13]
2021/7/16 下午2:21:37    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [na:1.8.0_202]
2021/7/16 下午2:21:37    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [na:1.8.0_202]
2021/7/16 下午2:21:37    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-9.0.13.jar!/:9.0.13]
2021/7/16 下午2:21:37    at java.lang.Thread.run(Thread.java:748) [na:1.8.0_202]
2021/7/16 下午2:21:37Caused by: com.fasterxml.jackson.databind.JsonMappingException: Unexpected end-of-input in VALUE_STRING
2021/7/16 下午2:21:37 at [Source: (PushbackInputStream); line: 1, column: 1487] (through reference chain: com.faujor.budget.dataobject.BudgetMaterialCost["customerType"])
2021/7/16 下午2:21:37    at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:394) ~[jackson-databind-2.9.7.jar!/:2.9.7]
2021/7/16 下午2:21:37    at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:353) ~[jackson-databind-2.9.7.jar!/:2.9.7]
2021/7/16 下午2:21:37    at com.fasterxml.jackson.databind.deser.BeanDeserializerBase.wrapAndThrow(BeanDeserializerBase.java:1711) ~[jackson-databind-2.9.7.jar!/:2.9.7]
2021/7/16 下午2:21:37    at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:371) ~[jackson-databind-2.9.7.jar!/:2.9.7]
2021/7/16 下午2:21:37    at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserialize(BeanDeserializer.java:159) ~[jackson-databind-2.9.7.jar!/:2.9.7]
2021/7/16 下午2:21:37    at com.fasterxml.jackson.databind.ObjectMapper._readMapAndClose(ObjectMapper.java:4013) ~[jackson-databind-2.9.7.jar!/:2.9.7]
2021/7/16 下午2:21:37    at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3084) ~[jackson-databind-2.9.7.jar!/:2.9.7]
2021/7/16 下午2:21:37    at org.springframework.http.converter.json.AbstractJackson2HttpMessageConverter.readJavaType(AbstractJackson2HttpMessageConverter.java:239) ~[spring-web-5.1.3.RELEASE.jar!/:5.1.3.RELEASE]
2021/7/16 下午2:21:37    ... 64 common frames omitted
2021/7/16 下午2:21:37Caused by: com.fasterxml.jackson.core.io.JsonEOFException: Unexpected end-of-input in VALUE_STRING
2021/7/16 下午2:21:37 at [Source: (PushbackInputStream); line: 1, column: 2977]
2021/7/16 下午2:21:37    at com.fasterxml.jackson.core.base.ParserMinimalBase._reportInvalidEOF(ParserMinimalBase.java:594) ~[jackson-core-2.9.7.jar!/:2.9.7]
2021/7/16 下午2:21:37    at com.fasterxml.jackson.core.base.ParserMinimalBase._reportInvalidEOF(ParserMinimalBase.java:571) ~[jackson-core-2.9.7.jar!/:2.9.7]
2021/7/16 下午2:21:37    at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._loadMoreGuaranteed(UTF8StreamJsonParser.java:2340) ~[jackson-core-2.9.7.jar!/:2.9.7]
2021/7/16 下午2:21:37    at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._finishString2(UTF8StreamJsonParser.java:2425) ~[jackson-core-2.9.7.jar!/:2.9.7]
2021/7/16 下午2:21:37    at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._finishAndReturnString(UTF8StreamJsonParser.java:2405) ~[jackson-core-2.9.7.jar!/:2.9.7]
2021/7/16 下午2:21:37    at com.fasterxml.jackson.core.json.UTF8StreamJsonParser.getText(UTF8StreamJsonParser.java:269) ~[jackson-core-2.9.7.jar!/:2.9.7]
2021/7/16 下午2:21:37    at com.fasterxml.jackson.databind.deser.std.StringDeserializer.deserialize(StringDeserializer.java:35) ~[jackson-databind-2.9.7.jar!/:2.9.7]
2021/7/16 下午2:21:37    at com.fasterxml.jackson.databind.deser.std.StringDeserializer.deserialize(StringDeserializer.java:10) ~[jackson-databind-2.9.7.jar!/:2.9.7]
2021/7/16 下午2:21:37    at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:127) ~[jackson-databind-2.9.7.jar!/:2.9.7]
2021/7/16 下午2:21:37    at com.fasterxml.jackson.databind.deser.BeanDeserializer.deserializeFromObject(BeanDeserializer.java:369) ~[jackson-databind-2.9.7.jar!/:2.9.7]
2021/7/16 下午2:21:37    ... 68 common frames omitted

后端报错的字段:
image.png
前端异常:
image.png
前端请求:
image.png
前端JSON:
image.png
image.png
前端JSON结尾是报错的那个字段, 转的时候也没有问题呀:
image.png

{
    "id": "",
    "userCode": "000admin",
    "untaxedCost": "",
    "groupId": "46d93d0fbaf44cef87a7710985b439a1",
    "taxRate": "0.13",
    "drawerOutput": "9",
    "matkl": "B441",
    "materialsSum": "",
    "accessoriesPrice": "0.15",
    "ingredientsPrice": "0.19",
    "inputPrice": "1",
    "processCostInputPrice": "1",
    "contributionMargin": "",
    "prodLevelCate": "地坪",
    "kzkfg": "",
    "excludingTax": "3842428.9174",
    "untaxedA": "",
    "materialsCostTotal": "",
    "materialATotal": "",
    "untaxedBillPriceTotal": "",
    "untaxedBillPrice": "",
    "productLevel5": "X901002130041",
    "productLevel5Text": "聚合型地坪骨料",
    "wbsCode": "",
    "changeMterial": "",
    "targerMterial": "",
    "budgetPlan": "0",
    "versionExplain": "",
    "targerQuantity": "",
    "changeQantity": "",
    "quantityChange": "",
    "quantityDifference": "",
    "code": "",
    "techName": "",
    "systemConsumptionName": "",
    "materialCode": "B441AAAA6005",
    "materialName": "SP-1013N 水性环氧自流平砂浆C组分(带托盘)",
    "colorNumber": "",
    "colorZone": "",
    "sendFactory": "5000",
    "specAndMode": "14.4KG",
    "productLevel4Text": "无机地坪",
    "productLevel4": "X90100213",
    "productLevel6Text": "SP-1013N",
    "productLevel6": "X901002130041X0159",
    "netWeight": "14.4",
    "unitName": "DR",
    "unitConsumption": "10",
    "usableArea": "10",
    "referenceQuantity": "6.94",
    "quantity": "101",
    "materialA": "43.2",
    "billPrice": "32.4",
    "materialCostPrice": "17.67",
    "inputTax": "",
    "transCost": "",
    "transCostDutyCycle": "",
    "projBeloCity": "杭州市",
    "processCost": "",
    "processCostDutyCycle": "",
    "materialCost": "",
    "rmcc": "",
    "discount": "",
    "contMargin": "",
    "fixedCost": "",
    "profitNotax": "",
    "customerType": "S12"
}
回复
阅读 269
1 个回答

datatype试试text ,我猜测估计是你发送的是个字符串,而你的datatype指定类型不对
但是这么写我感觉不太好。
前端应该是是POST BODY发送这个对象,而不是发送字符串。
后端应该建立对应的DO来接收requestBody

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
你知道吗?

宣传栏