Environment:
- Spring 2.3.0.RELEASE
- JDK 1.8
When I use spring.mvc.servlet.path config in application.yml or application.properties,
I did spring.mvc.servlet.path = /test,
at the same time,I had TestController,
used @GetMapping("/test") at one method,
and used @GetMapping("/test1") at other method.
Some problems happened when I tested.
Steps to reproduce:
- Add
spring.mvc.servlet.path=/testin application.properties. - Define Controller,use
@RestControllerin 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,Why?The above URL can be visited,it can not.
In fact,I find that WebFlux use spring.webflux.base-path=/test has some problems
This is link of My demo: https://github.com/DogeC0in/BugFinder
Comment From: wilkinsona
The behaviour you have observed is due to UrlPathHelper in Spring MVC which is part of Spring Framework. @rstoyanchev has responded on the duplicate issue that you opened. In the interests of keeping things in one place, I'm going to close this issue.