Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

java - 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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...