Results 1 to 3 of 3

Thread: ReST Controller Conflicting URI Patterns

  1. #1
    Join Date
    Mar 2006
    Posts
    10

    Default ReST Controller Conflicting URI Patterns

    With Spring 3 (3.0.5-RELEASE), is it possible to set up a ReSTful Controller (using the @Controller annotation) to respond to different, but conflicting, URI patterns with a precedence rule?

    For example, can I have two methods as follows?

    @RequestMapping(value = "/profile/{profileId}", method = RequestMethod.GET)
    public ModelAndView getProfile(final @RequestParam(value = "profileId") String pProfileId) {
    ...
    }

    and

    @RequestMapping(value = "/profile/current", method = RequestMethod.GET)
    public ModelAndView getCurrentProfile() {
    ...
    }

    and if so, how do I ensure that the constant form (e.g. "/profile/current") of the URI takes precedence over the parameterized form (e.g. "/profile/{profileId}") - i.e. it does not think that "current" is a profile ID.

  2. #2
    Join Date
    Aug 2006
    Location
    Brooklyn
    Posts
    556

    Default

    Have you tried it? Does it not work?

  3. #3
    Join Date
    Mar 2006
    Posts
    10

    Default My Mistake

    I tried it, as discussed, and it did not work - I would get an error indicating that my request was not valid.

    After much troubleshooting, I realised that I used @RequestParam where I should have used @PathVariable.

    i.e.

    Code:
        @RequestMapping(value = "/profile/{profileId}", method = RequestMethod.GET)
        public ModelAndView getProfile(final @PathVariable(value = "profileId") String pProfileId) {
            ...
        }
    It is all sorted now

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •