Spring Boot应用程序中未插入尾部斜杠 [英] Trailing slash is not inserted in Spring Boot application

查看:185
本文介绍了Spring Boot应用程序中未插入尾部斜杠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Spring Boot中的Tomcat不在URL的上下文名称后插入尾部斜杠.

Tomcat in Spring Boot is not inserting the trailing slash after context name at URL.

应在未指定服务器的情况下自动完成.

It should be done automatically by server case it was not specified.

示例: 服务器会将/user更改为/user/

Example: /user would be changed to /user/ by server

有人知道如何启用它吗?

Does anyone have any idea how to enable it?

谢谢

推荐答案

不应插入斜杠.

仅在contextRoot(在Spring Boot应用程序中通常为/的情况下,才这样做),因此请转到 http://your.server.here:8080 将重定向到 http://您的网站. server.here:8080/)

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/)

重定向的用例是什么?

如果您需要此功能,则添加一个可以为您进行重定向的过滤器应该很简单.

In case you want this functionality, it should be quite trivial to add a filter that would do the redirects for you.

查看有关此问题的答案,以 Spring MVC:带有斜杠重定向的网址

Check out the answers on this question for how to do it Spring MVC: urls with trailing slash redirection

这篇关于Spring Boot应用程序中未插入尾部斜杠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆