简体   繁体   English

Spring Boot 应用程序中未插入尾部斜杠

[英]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.

相关问题 带有嵌入式 Tomcat 的 Spring Boot 应用程序在请求 /contextPath 时不重定向到 https 而不使用尾部斜杠 - Spring Boot application with embedded Tomcat behind reverse proxy not redirecting to https when asking for /contextPath without trailing slash Spring-boot 休息 api。 截断尾部斜杠 - Spring-boot rest api. Truncate trailing slash 你如何在 spring boot 3 中忽略 webflux 中的尾部斜杠? - How do you ignore trailing slash in webflux in spring boot 3? Java Spring MVC应用程序仅接受带有斜杠的POST请求 - Java Spring MVC application accepts POST requests only with trailing slash 如何阻止spring-boot Embedded-undertw添加尾部斜杠 - How to stop spring-boot embedded-undertow from adding trailing slash Spring Boot-请求映射将不接受尾部斜杠或多个目录 - Spring Boot - Request Mapping won't accept trailing slash or multiple directories 忽略在 spring 引导管理应用程序的 yaml 配置中指定斜杠字符 - Ignore specify slash character in yaml config for spring boot admin application Spring HATEOAS ControllerLinkBuilder删除尾部斜杠? - Spring HATEOAS ControllerLinkBuilder removes trailing slash? Spring MVC RequestMapping 需要尾部斜杠 - Spring MVC RequestMapping requires trailing slash 获取请求仅适用于尾部斜杠(Spring REST注释) - Get request only works with trailing slash (spring REST annotations)
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM