-
Notifications
You must be signed in to change notification settings - Fork 38.4k
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
Implicit /** mapping on type-level @RequestMapping [SPR-5631] #10302
Comments
Grzegorz Borkowski commented As this discussion was started here: http://grzegorzborkowski.blogspot.com/2009/03/test-drive-of-spring-30-m2-rest-support.html, I copy my comments from there to here. They are perhaps arguable, but I believe it is better to keep all arguments in one place: "...the fact that you always needed to end class-level request mappings with ** bothered me in the past..." The point is that according to JavaDoc, it is actually not required. See JavaDoc: |
Grzegorz Borkowski commented Some additional comments:
|
Arjen Poutsma commented People do use
This one of our unit test, so I could just change it to reflect any new behavior, but that would defy the point of a unit test, wouldn't it? So, I came up with the following rules:
I believe this algorithm does not break backwards compatibility, while also allowing for hierarchical mappings. |
Grzegorz Borkowski commented I'm not sure if you understood me correctly. I didn't say people don't use The rules you describe sounds ok. I'm not sure though if there will be difference for /x/.do and /x/ mappings on type level. From the point of view of REST services, the /x/.do is of less importance. So for me the /x/ is much more important. However it would be good to have consistent rules for both wildcard mapping types. Your rule 3(a) means that my point #2 from previous comment is solved in favor of "method-level mappings are always relative to type-level, even if they start from / character". That's ok for me. |
Grzegorz Borkowski commented Oups, liks like Jira treats * characters as bold-markers... Not good in this case :) |
Grzegorz Borkowski commented From my point of view, target behavior (to be used in tests, for example) for the RESTful controller like this:
should be following:
|
Arjen Poutsma commented I have a testcase like that in place. Making it work while not breaking backwards compatibility is not trivial, however. Working on that now. |
Arjen Poutsma commented It took a while, but this is fixed in SVN, and will be part of M3. |
Grzegorz Borkowski commented I'm testing M3 now. Looks like mappings work properly with the following setup:
Request for URLs: /projects, /projects/, /projects/myproject, /projects/myproject/ are dispatched properly. However, if you add leading slash at method level, like this:
then for request /projects and /projects/ the exception is thrown: |
Arjen Poutsma commented This seems to be the same as the issue filed by Keith: #10396. Will fix asap. As for the semantics for method-level annotations starting with a slash: it is supposed to be relative to the type level. So in your example, the full URL handled is /projects/{projectName}. To me, that seemed to be the most natural solution. |
Grzegorz Borkowski commented Yes, I would also prefer it be solved this way. |
Arjen Poutsma opened SPR-5631 and commented
When a
@Controller
has a class-level@RequestMapping
annotation, with further sub-paths mappings defined on the methods, it makes sense to implicitely add /** to the type-level annotation.Since method mappings can just have a RequestMethod (GET or POST)on it, with no further path information, we have to be a little clever about this.
Issue Links:
@RequestMapping
semantics when class-level and method-level mappings used together@RequestMapping
matching should be insensitive to trailing slashesReferenced from: commits 6121da9, 65afc80, acc8492
The text was updated successfully, but these errors were encountered: