首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >当第一次测试嵌入的tomcat是否工作时,Spring Boot会抛出一个错误

当第一次测试嵌入的tomcat是否工作时,Spring Boot会抛出一个错误
EN

Stack Overflow用户
提问于 2021-02-16 13:29:01
回答 1查看 314关注 0票数 0

我刚刚设置了一个Spring应用程序,并希望测试tomcat服务器是否会返回一个空白页面,但是它在我的IDE中抛出了以下错误信息:

代码语言:javascript
运行
复制
  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::                (v2.4.2)

2021-02-16 14:21:45.297  INFO 6956 --- [           main] com.test.gifly.GiflyApplication          : Starting GiflyApplication using Java 15.0.2 on LAPTOP-LJRSO4L6 with PID 6956 (D:\Coding\gifly\build\classes\java\main started by Dominik Lovetinsky in D:\Coding\gifly)
2021-02-16 14:21:45.302  INFO 6956 --- [           main] com.test.gifly.GiflyApplication          : No active profile set, falling back to default profiles: default
2021-02-16 14:21:46.102  INFO 6956 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8080 (http)
2021-02-16 14:21:46.119  INFO 6956 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2021-02-16 14:21:46.120  INFO 6956 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.41]
2021-02-16 14:21:46.211  INFO 6956 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2021-02-16 14:21:46.212  INFO 6956 --- [           main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 859 ms
2021-02-16 14:21:46.367  INFO 6956 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2021-02-16 14:21:46.545  INFO 6956 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 8080 (http) with context path ''
2021-02-16 14:21:46.554  INFO 6956 --- [           main] com.test.gifly.GiflyApplication          : Started GiflyApplication in 1.607 seconds (JVM running for 2.285)
2021-02-16 14:22:00.025  INFO 6956 --- [nio-8080-exec-1] o.apache.coyote.http11.Http11Processor   : Error parsing HTTP request header
 Note: further occurrences of HTTP request parsing errors will be logged at DEBUG level.

java.lang.IllegalArgumentException: Invalid character found in method name [0x160x030x010x020x000x010x000x010xfc0x030x030x870x97`F0xe7Q[0x960x02<0xe40xde]\0x06l0xc3G0xfa0xcc0x8d0x0d0x00X0xca;V0x160x9a0xef0xca0xc1]. HTTP method names must be tokens
    at org.apache.coyote.http11.Http11InputBuffer.parseRequestLine(Http11InputBuffer.java:417) ~[tomcat-embed-core-9.0.41.jar:9.0.41]
    at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:261) ~[tomcat-embed-core-9.0.41.jar:9.0.41]
    at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:65) ~[tomcat-embed-core-9.0.41.jar:9.0.41]
    at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:888) ~[tomcat-embed-core-9.0.41.jar:9.0.41]
    at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1597) ~[tomcat-embed-core-9.0.41.jar:9.0.41]
    at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) ~[tomcat-embed-core-9.0.41.jar:9.0.41]
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130) ~[na:na]
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630) ~[na:na]
    at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) ~[tomcat-embed-core-9.0.41.jar:9.0.41]
    at java.base/java.lang.Thread.run(Thread.java:832) ~[na:na]

2021-02-16 14:22:00.025  INFO 6956 --- [nio-8080-exec-2] o.apache.coyote.http11.Http11Processor   : Error parsing HTTP request header
 Note: further occurrences of HTTP request parsing errors will be logged at DEBUG level.

我已经指定的唯一代码是主java类和以下Controller类:

代码语言:javascript
运行
复制
package com.test.gifly.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class GifController {

    @RequestMapping(value = "/")
    @ResponseBody
    public String listGifs(){
        return "List fo all the GIFs!";
    }

}

有谁知道,这个错误是从哪里来的,以及如何修复它?

  • 看起来,我的请求映射也不起作用。
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-02-16 13:38:28

您能否尝试将@RequestMapping更改为@GetMapping?还请检查您是否要从https而不是http开始访问该网站。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66225279

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档