-
Notifications
You must be signed in to change notification settings - Fork 37.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
spring.mvc.servlet.path config cause something strange #25339
Comments
Please avoid cross-posting: |
This is a very old part of the code. My best guess is as that this is so for 2 reasons:
My advice is to not use mappings where the servletPath prefix is also duplicated in an application mapping. I would also advise against using a mapping by servletPath prefx, and against relying on the servletPath in any way, in the first place if you can avoid it. It's fraught with bigger issues then just such corner cases. If you must have a Servlet mapped to "/test" then in your application mappings use "/test1" and "/test2", and if you want also one for "/test" which correspond to URLs "/test/test1", "/test/test2", and "/test" respectively. |
@rstoyanchev |
@DogeC0in |
Correct, you need to avoid having both the Servlet and an application mapping using the exact same path because they overlap. Make the application mapping different, e.g. "/test1" and "/test2" so you'll have "/test/test1" and "/test/test2" working correctly. Then input path "/test" is for the whole Servlet. |
Environment:
Spring 2.3.0.RELEASE
JDK 1.8
Steps to reproduce:
Add
spring.mvc.servlet.path=/test
in application.properties.Define Controller,use
@RestController
in controller class,then use
@GetMapping("/test")
at one method,finally,use
@GetMapping("/test1")
at other method.start project,visit urls that I want to test.
I expect that:
I visit http://localhost:8080/test/test, I got result.
I visit http://localhost:8080/test/test1, I got result too.
I visit http://localhost:8080/test, HTTP ERROR 404
I visit http://localhost:8080/test1, HTTP ERROR 404
Actually:
I visit http://localhost:8080/test/test, I got result.
I visit http://localhost:8080/test/test1, I got result too.
I visit http://localhost:8080/test, I got result.It confused me!
I visit http://localhost:8080/test1, HTTP ERROR 404
In fact,I find that
WebFlux
usespring.webflux.base-path=/test
has some problemsThis is link of My demo: https://github.com/DogeC0in/BugFinder
The text was updated successfully, but these errors were encountered: