[英]How to stop spring-boot embedded-undertow from adding trailing slash
When i call the context root of my spring-boot application " localhost:8080/api/players ", which is mapped in a RestController method by the annotation @GetMapping(path= {"/",""}), undertow alway redirect (httpstatus: 307 Temporary redirect) to " localhost:8080/api/players/ " adding trailing slash at the end. 当我将我的spring-boot应用程序的上下文根称为“ localhost:8080 / api / players ”时,该上下文根由在RestController方法中通过注解@GetMapping(path = {“ /”,“”})映射,始终始终重定向(httpstatus:307临时重定向)到“ localhost:8080 / api / players / ”,并在末尾添加斜杠。
My application context-root is indeed /api/players as defined in spring-boot application.properties file ( server.servlet.context-path=/api/players ) 我的应用程序上下文根目录确实是/ api / players,如春季启动的application.properties文件( server.servlet.context-path = / api / players )中所定义
I've tried with embedded-tomcat and it works correctly by setting the property server.tomcat.redirect-context-root=false 我已经尝试过Embedded-tomcat,并且通过设置属性server.tomcat.redirect-context-root = false可以正常工作
There is a way to configure undertow to act like tomcat? 有没有一种方法可以将underwow配置为像雄猫一样?
Peering into the sourcecode for undertow a bit, it looks like the relevant code is here in ServletInitialHandler.java
, which will issue a 307 redirect status code in the case that the request is an upgrade request... unless the request is an HTTP 2 upgrade request. ServletInitialHandler.java
一下ServletInitialHandler.java
的源代码,看起来相关代码在ServletInitialHandler.java
,在请求是升级请求的情况下,它将发出307重定向状态代码...除非请求是HTTP 2升级要求。 This doesn't seem to be configurable by the server, although there is some attempt to avoid the redirect based on what the client does. 尽管似乎有人尝试根据客户端的操作来避免重定向,但这似乎不是服务器可配置的。
It's probably worthwhile to look at your HTTP requests, understand better if your HTTP client is actually making an upgrade request, and then consider either accepting this fact, or changing the client to make a different kind of request (possibly by making it send the HTTP2 upgrade request header). 查看您的HTTP请求,了解您的HTTP客户端是否实际发出了升级请求,然后考虑接受此事实,或者考虑更改客户端以发出不同类型的请求(可能通过使其发送HTTP2),可能是值得的升级请求标头)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.