@sur-pavel

Как избавиться от ошибки Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported"?

Spring boot, h2.
Дао
ProjectRepository extends JpaRepository<Project, Long>...

В контроллере
@PostMapping("/projects")
    public Project createProject(@Valid @RequestBody Project project) {
        return projectRepository.save(project);
    }

Post запрос выдаёт:
2020-07-08 11:23:25.544 DEBUG 11636 --- [nio-8080-exec-2] o.apache.coyote.http11.Http11Processor   : Error parsing HTTP request header

java.io.EOFException: null
	at org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper.fillReadBuffer(NioEndpoint.java:1231) ~[tomcat-embed-core-9.0.36.jar:9.0.36]
	at org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper.read(NioEndpoint.java:1141) ~[tomcat-embed-core-9.0.36.jar:9.0.36]
	at org.apache.coyote.http11.Http11InputBuffer.fill(Http11InputBuffer.java:780) ~[tomcat-embed-core-9.0.36.jar:9.0.36]
	at org.apache.coyote.http11.Http11InputBuffer.parseRequestLine(Http11InputBuffer.java:356) ~[tomcat-embed-core-9.0.36.jar:9.0.36]
	at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:260) ~[tomcat-embed-core-9.0.36.jar:9.0.36]
	at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) [tomcat-embed-core-9.0.36.jar:9.0.36]
	at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:868) [tomcat-embed-core-9.0.36.jar:9.0.36]
	at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1590) [tomcat-embed-core-9.0.36.jar:9.0.36]
	at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) [tomcat-embed-core-9.0.36.jar:9.0.36]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) [na:1.8.0_251]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [na:1.8.0_251]
	at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) [tomcat-embed-core-9.0.36.jar:9.0.36]
	at java.lang.Thread.run(Unknown Source) [na:1.8.0_251]
2020-07-08 11:23:25.545 DEBUG 11636 --- [nio-8080-exec-2] o.apache.coyote.http11.Http11Processor   : Socket: [org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper@27f578d4:org.apache.tomcat.util.net.NioChannel@7e6521ae:java.nio.channels.SocketChannel[connected local=/0:0:0:0:0:0:0:1:8080 remote=/0:0:0:0:0:0:0:1:50099]], Status in: [OPEN_READ], State out: [CLOSED]
2020-07-08 11:23:25.546 DEBUG 11636 --- [nio-8080-exec-2] o.apache.tomcat.util.threads.LimitLatch  : Counting down[http-nio-8080-exec-2] latch=2
2020-07-08 11:23:25.546 DEBUG 11636 --- [nio-8080-exec-2] org.apache.tomcat.util.net.NioEndpoint   : Calling [org.apache.tomcat.util.net.NioEndpoint@3cee8c55].closeSocket([org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper@27f578d4:org.apache.tomcat.util.net.NioChannel@7e6521ae:java.nio.channels.SocketChannel[connected local=/0:0:0:0:0:0:0:1:8080 remote=/0:0:0:0:0:0:0:1:50099]])
2020-07-08 11:23:25.582 DEBUG 11636 --- [nio-8080-exec-1] org.apache.tomcat.util.http.Parameters   : Set query string encoding to UTF-8
2020-07-08 11:23:25.593 DEBUG 11636 --- [nio-8080-exec-1] o.a.c.authenticator.AuthenticatorBase    : Security checking request POST /projects/
2020-07-08 11:23:25.594 DEBUG 11636 --- [nio-8080-exec-1] org.apache.catalina.realm.RealmBase      :   No applicable constraints defined
2020-07-08 11:23:25.603 DEBUG 11636 --- [nio-8080-exec-1] o.a.c.a.jaspic.AuthConfigFactoryImpl     : Loading persistent provider registrations from [C:\Users\sur-p\AppData\Local\Temp\tomcat.8000510046453634187.8080\conf\jaspic-providers.xml]
2020-07-08 11:23:25.604 DEBUG 11636 --- [nio-8080-exec-1] o.a.c.authenticator.AuthenticatorBase    : Not subject to any constraint
2020-07-08 11:23:25.612  INFO 11636 --- [nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
2020-07-08 11:23:25.612  INFO 11636 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2020-07-08 11:23:25.612 DEBUG 11636 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Detected StandardServletMultipartResolver
2020-07-08 11:23:25.626 DEBUG 11636 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : enableLoggingRequestDetails='false': request parameters and headers will be masked to prevent unsafe logging of potentially sensitive data
2020-07-08 11:23:25.626  INFO 11636 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 14 ms
2020-07-08 11:23:25.647 DEBUG 11636 --- [nio-8080-exec-1] org.apache.tomcat.util.http.Parameters   : Set encoding to UTF-8
2020-07-08 11:23:25.647 DEBUG 11636 --- [nio-8080-exec-1] org.apache.tomcat.util.http.Parameters   : Start processing with input [title=second]
2020-07-08 11:23:25.648 DEBUG 11636 --- [nio-8080-exec-1] o.s.web.servlet.DispatcherServlet        : POST "/projects/", parameters={masked}
2020-07-08 11:23:25.663 DEBUG 11636 --- [nio-8080-exec-1] s.w.s.m.m.a.RequestMappingHandlerMapping : Mapped to ru.surpavel.bugtrackingsystem.controller.ProjectController#createProject(Project)
2020-07-08 11:23:25.664 DEBUG 11636 --- [nio-8080-exec-1] o.j.s.OpenEntityManagerInViewInterceptor : Opening JPA EntityManager in OpenEntityManagerInViewInterceptor
2020-07-08 11:23:25.719 DEBUG 11636 --- [nio-8080-exec-1] .w.s.m.m.a.ServletInvocableHandlerMethod : Could not resolve parameter [0] in public ru.surpavel.bugtrackingsystem.entity.Project ru.surpavel.bugtrackingsystem.controller.ProjectController.createProject(ru.surpavel.bugtrackingsystem.entity.Project): Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported
  • Вопрос задан
  • 108 просмотров
Решения вопроса 1
sergey-gornostaev
@sergey-gornostaev Куратор тега Spring
Седой и строгий
Просто уберите аннотацию RequestBody.
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы
03 авг. 2020, в 14:53
1200 руб./за проект
03 авг. 2020, в 14:42
5 руб./за проект
03 авг. 2020, в 14:35
20 руб./за проект