Results 1 to 3 of 3

Thread: Various Spring MVC RequestMapping configuration questions

  1. #1
    Join Date
    Nov 2007
    Posts
    177

    Default Various Spring MVC RequestMapping configuration questions

    Hi,

    I have several (albeit related) questions about Spring MVC RequestMapping configuration:

    1. Say I have a type-level RequestMapping annotation as follows:
      Code:
       @RequestMapping("/root/")
      What is the difference between adding this method-level RequestMapping:
      Code:
      @RequestMapping(value="leaf")
      and that one?
      Code:
      @RequestMapping(value="/leaf")
      Notice the leading slash in second method-level mapping.

    2. What is the difference between having this type-level RequestMapping:
      Code:
      @RequestMapping("/root/")
      and that one ?
      Code:
      @RequestMapping("/root/*")
      Notice the star in second mapping.

    3. Say I already have a type-level RequestMapping annotation. How do I override the type-level mapping at the method-level so that the type-level mapping is ignored (for a given controller)?


    Regards,

    Julien.

  2. #2
    Join Date
    Jun 2006
    Location
    The Netherlands
    Posts
    13,629

    Default

    1. There should be no difference as they are combined.
    2. It depends on your configuration, by default /root/ is mapped to /root/ and /root/*. /root/ matches only the index /root/* matches everything after /root/
    3. No you cannot... They are always combined, class level is coarse grained and method level is finer grained.
    Marten Deinum
    Java Consultant / Pragmatist / Open Source Enthousiast / Author


    Pro Spring MVC: With Web Flow
    Conspect

    Have you read the reference guide.
    Use the [ code ] tags, young padawan

  3. #3
    Join Date
    Nov 2007
    Posts
    177

    Default

    Thanks Marten!

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
  •