Announcement Announcement Module
Collapse
No announcement yet.
Various Spring MVC RequestMapping configuration questions Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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.

    Comment


    • #3
      Thanks Marten!

      Comment

      Working...
      X