You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With the following code, the org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping fails to #determineUrlsForHandler.
@Controller
@RequestMapping("/users")
public class DemoController {
@RequestMapping(value = "/users", method = GET)
public String getUsers()
{
return "users/users";
}
}
The wanted URL mapping is '/users/users' but the generated path is '/users'. So when browsing /users/users we got HTTP 404.
The error is due to the use of org.springframework.util.AntPathMatcher.combine(String, String) to concatenate the type-level path and the method-level path that only return the method-level path which is not expected.
The combine method return the second method argument pattern2 when the pattern1 matches pattern2.
I don't known if it is the AntPathMatcher.combine(...) method which is wrong or the use of it by org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping.determineUrlsForHandler(String)
Apologies we didn't get to this for 3.1 even though a related issue (#13500) was fixed. Maybe you already know this but a temporary workaround would be to move the separating slash to the class-level annotation:
@Controller
@RequestMapping("/users/")
public class DemoController {
@RequestMapping(value = "users", method = GET)
public String getUsers()
{
return "users/users";
}
}
Ludovic Praud opened SPR-7970 and commented
With the following code, the org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping fails to #determineUrlsForHandler.
The wanted URL mapping is
'/users/users'
but the generated path is'/users'
. So when browsing/users/users
we got HTTP 404.The error is due to the use of
org.springframework.util.AntPathMatcher.combine(String, String)
to concatenate the type-level path and the method-level path that only return the method-level path which is not expected.The combine method return the second method argument pattern2 when the pattern1 matches pattern2.
I don't known if it is the
AntPathMatcher.combine(...)
method which is wrong or the use of it byorg.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping.determineUrlsForHandler(String)
Affects: 3.0.5
Issue Links:
@RequestMapping
not working properlyReferenced from: commits 9833a4c
The text was updated successfully, but these errors were encountered: