简体   繁体   中英

Trailing slash is not inserted in Spring Boot application

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.

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM