Issue Details (XML | Word | Printable)

Key: SPR-4470
Type: Improvement Improvement
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Juergen Hoeller
Reporter: Chris Lee
Votes: 0
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Spring Framework

@RequestMapping has no means to combine method-name-based invocation with a request method

Created: 17/Feb/08 02:31 PM   Updated: 18/Feb/08 06:47 AM
Component/s: SpringWEB
Affects Version/s: None
Fix Version/s: 2.5.2

Time Tracking:
Not Specified

Environment: Nightly snapshot 2.5.2 20080216-405
Issue Links:
Related
 


 Description  « Hide
Consider the below controller; the goal is to map multiple methods, accessible via POST only, using the naming scheme from InternalPathMethodNameResolver. This does not work because:

1) The naming scheme from InternalPathMethodNameResolver is only invoked is the @RequestParam is empty (no value, method, or parameters);
2) The request method cannot be specified at the type level (explicitly prohibited by DefaultAnnotationHandlerMapping)

Our use case for this is converting several legacy Servlets that do an if/else match on the URL in doPost() - it would be trivial to convert these if the POST could be combined with the InternalPathMethodNameResolver (ideally the POST could be defaulted at the type level).

@Controller
    @RequestMapping("/foo/*.do")
    public static class MultiMethodController
    {
        @RequestMapping(method = RequestMethod.POST)
        public void withWriter( Writer w )
        {
            System.out.println( "writWriter invoked" );
        }

        @RequestMapping(method = RequestMethod.POST)
        public void withWriter2( Writer w )
        {
            System.out.println( "writWriter2 invoked" );
        }
    }

 All   Comments   Work Log   Change History   FishEye   Builds      Sort Order: Ascending order - Click to sort in descending order
Juergen Hoeller added a comment - 17/Feb/08 05:01 PM
For a start, I've revised the matching to apply method name resolution for any equal mappings, even with method and/or params specified (as long as the mapping is equivalent across multiple methods, we try method name resolution before throwing an exception).

I'll consider allowing for request method mappings at the type level as well.

Juergen

Chris Lee added a comment - 17/Feb/08 05:06 PM
Excellent, thank you!

Juergen Hoeller added a comment - 18/Feb/08 06:47 AM
Fixed for 2.5.2 in terms of considering method names for handler methods that are already narrowed based on the specific request method (with multiple methods expressing identical path-less mappings).

Juergen