[英]Trailing slash is not inserted in Spring Boot application
Tomcat in Spring Boot is not inserting the trailing slash after context name at URL. Spring Boot 中的 Tomcat 未在 URL 的上下文名称后插入尾部斜杠。
It should be done automatically by server case it was not specified.它应该由未指定的服务器情况自动完成。
Example: /user
would be changed to /user/
by server示例: /user
将被服务器更改为/user/
Does anyone have any idea how to enable it?有谁知道如何启用它?
Thanks谢谢
It is not supposed to insert the trailing slash.它不应该插入尾部斜杠。
It only does that in the case of the contextRoot (which in a Spring Boot application is usally /, so going to http://your.server.here:8080 will redirect to http://your.server.here:8080/ )它仅在 contextRoot 的情况下(在 Spring Boot 应用程序中通常是 /,因此转到http://your.server.here:8080将重定向到http://your.server.here:8080/ )
What is your use case for the redirects?你的重定向用例是什么?
In case you want this functionality, it should be quite trivial to add a filter that would do the redirects for you.如果您需要此功能,添加一个可以为您执行重定向的过滤器应该很简单。
Check out the answers on this question for how to do it Spring MVC: urls with trailing slash redirection查看有关如何执行此问题的答案Spring MVC: urls with trailing slash redirection
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.