我有一个控制器类,其中有几个方法,其中一个是应该接受POST请求的方法。
当我试图发送一个POST请求时,我得到一个错误,说:
org.springframework.http.converter.HttpMessageNotReadableException: Required request body is missing: public com.dmall.cx.salecontract.common.entity.CxHttpResult<java.lang.String> com.dmall.cx.salecontract.web.controller.CxContractGoodsController.exceptionResolve(com.dmall.cx.salecontract.service.dto.CxContractGoodsDTO) throws java.lang.Exception
at org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.readWithMessageConverters(RequestResponseBodyMethodProcessor.java:160)
at org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.resolveArgument(RequestResponseBodyMethodProcessor.java:130)
at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:124)
at org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:157)
at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:133)
at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:102)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:895)
at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:800)
at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1038)
at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:942)
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:998)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:901)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:661)
at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:875)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:742)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.CorsFilter.doFilterInternal(CorsFilter.java:96)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:200)
at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:493)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:81)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:342)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:800)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:806)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1498)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)
POST请求的ContentType是应用程序/x-ww-form-urlencoded; charset=UTF-8。表单数据为:
{"id":38,"contractStatus":null,"contractNo":null,"abnormalDesc":"asdf%","abnormalCode":302,"abnormalStatus":1,"scheduleNo":"D6666","supplierCode":"100002","compensateValue":-2,"updateUserId":10000001,"goodsCode":"1063222","createUserId":10000001,"contractType":1,"goodsName":"sdfsdfsdf","discountType":2,"startDate":"2018-09-09","endDate":"2018-09-09","shopCodes":"1024","compensateType":1,"pContractNo":null,"compensateTypeDesc":"zzzz","createTimeDesc":"2019-04-19 11:17:48","abnormal":true,"skuId":null,"changeDesc":"1","isProfitDesc":"0","supplierName":null,"discountTypeDesc":"1","updateUser":"CxUser","createUser":"CxUser","createTime":1555643868000,"updateTime":1555661247000}
normaldesc
属性包含“%”。如果删除“%”,程序将运行良好,但当正文包含“%s”时,程序将无法正常运行。
尝试对请求中的特殊字符进行编码<代码>“%”是其中之一。
%
编码的等价物是%
,因此您的负载应该包含:“异常描述”:“asdf%”
。
这是必需的,因为您的内容类型
设置为应用程序/x-www-form-urlencoded
,因此应将其视为GET参数字符串。
基于Web中的示例创建了两个应用程序:Angular中的Frontend和customer)Angular URL:http://localhost:4200/Spring Boot URL:http://localhost:9020/(REST:http://localhost:9020/API/) 根据这里的专家对我前面问题的说明(https://stackoverflow.com/posts
问题内容: 将JSON数据从JSP传递到ResponseBody中的控制器时出错。 Ajax电话: 控制器: AppConfig.java @豆 请帮助我摆脱困境。我正在使用Spring 4,Jakson 2.3.0 如果我尝试POST请求,它将给出:org.springframework.web.HttpRequestMethodNotSupportedException:请求方法’POST’不
我收到了第三方的回复,如下所示 我们有课。 但是当我们转换时,我们会低于误差 错误com.openbet.commons.sdk.common.util.请求SenderImpl-在HTTP交换过程中意外的异常:org.springframework.http.converter.HttpMessageNotReadableExctive:JSON解析错误:无法反序列化的实例START_ARRAY
我创建了基于Web的应用程序示例:Angular的前端和spring boot mer客户的后端)Angular URL:http://localhost:4200/spring boot URL:http://localhost:9020/(REST:http://localhost:9020/API/) . . 应用程序.属性: > server.port=9020 spring.dataso
问题内容: 将JSON数据从JSP传递到ResponseBody中的控制器时出错。 Ajax电话: 控制器: AppConfig.java @豆 请帮助我摆脱困境。我正在使用Spring 4,Jakson 2.3.0 如果我尝试POST请求,它将给出:org.springframework.web.HttpRequestMethodNotSupportedException:请求方法’POST’不
我得到了<code>缺少的要求osgi.wiring。包…部署包时出错,缺少的包来自库(maven依赖项),因此包在其<code>类路径中 我的理解是:当使用来自另一个<code>OSGI捆绑包,但事实并非如此,这只是一个自制的库(没有部署到OSGI容器,甚至没有捆绑包),所以我一定不太明白