当前位置:   article > 正文

POSTMAN调试报错:“Content type ‘text/plain;charset=UTF-8‘ not supported”_charset=utf8 not supported

charset=utf8 not supported

问题描述:

        在使用POSTMAN进行接口调试时候,JavaIDE报错:Content type 'text/plain;charset=UTF-8' not supported。具体如下:

  1. org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'text/plain;charset=UTF-8' not supported
  2. at org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodArgumentResolver.readWithMessageConverters(AbstractMessageConverterMethodArgumentResolver.java:225)
  3. at org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.readWithMessageConverters(RequestResponseBodyMethodProcessor.java:158)
  4. at org.springframework.web.servlet.mvc.method.annotation.RequestResponseBodyMethodProcessor.resolveArgument(RequestResponseBodyMethodProcessor.java:131)
  5. at org.springframework.web.method.support.HandlerMethodArgumentResolverComposite.resolveArgument(HandlerMethodArgumentResolverComposite.java:121)
  6. at org.springframework.web.method.support.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:167)
  7. at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:134)
  8. at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105)
  9. at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878)
  10. at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792)
  11. at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87)
  12. at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:1040)
  13. at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:943)
  14. at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1006)
  15. at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:909)
  16. at javax.servlet.http.HttpServlet.service(HttpServlet.java:652)
  17. at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:883)
  18. at javax.servlet.http.HttpServlet.service(HttpServlet.java:733)
  19. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:227)
  20. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
  21. at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
  22. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
  23. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
  24. at com.github.xiaoymin.knife4j.spring.filter.ProductionSecurityFilter.doFilter(ProductionSecurityFilter.java:53)
  25. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
  26. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
  27. at com.github.xiaoymin.knife4j.spring.filter.SecurityBasicAuthFilter.doFilter(SecurityBasicAuthFilter.java:90)
  28. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
  29. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
  30. at org.springframework.web.filter.RequestContextFilter.doFilterInternal(RequestContextFilter.java:100)
  31. at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
  32. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
  33. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
  34. at org.springframework.web.filter.FormContentFilter.doFilterInternal(FormContentFilter.java:93)
  35. at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
  36. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
  37. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
  38. at org.springframework.boot.actuate.metrics.web.servlet.WebMvcMetricsFilter.doFilterInternal(WebMvcMetricsFilter.java:93)
  39. at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
  40. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
  41. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
  42. at org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:201)
  43. at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:119)
  44. at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:189)
  45. at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:162)
  46. at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
  47. at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:97)
  48. at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:542)
  49. at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:143)
  50. at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
  51. at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:78)
  52. at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:346)
  53. at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:374)
  54. at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65)
  55. at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:887)
  56. at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1684)
  57. at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
  58. at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
  59. at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
  60. at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
  61. at java.lang.Thread.run(Thread.java:748)
  62. 2024-01-21 19:15:56.024 [http-nio-51801-exec-1] ERROR c.h.common.exception.ExceptionCatch - catch exception:Content type 'text/plain;charset=UTF-8' not supported

 造成原因:

        数据传输格式不一致,POSTMAN默认是Text格式,而我需要传入的是JSON格式,所以就报错了。

解决方案:

        弄清楚数据传输格式,在调试时候选择相应的格式即可。

参考博客:HttpMediaTypeNotSupportedException: Content type ‘text/plain;charset=UTF-8‘ not supported_content type 'text/plain;charset=utf-8' not suppor-CSDN博客

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家小花儿/article/detail/864813
推荐阅读