Announcement Announcement Module
Collapse
No announcement yet.
Using @RequestMapping twice to a same method? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Using @RequestMapping twice to a same method?

    I am exploring more on SpringMVC Annotated style config.

    Is there way to do map two url to the same method? There seems to be compile error when I use @RequestMapping more than onces on either type level or method level.

    If not, how would I go about mapping /foo and /bar to the same controller/method?

    This used to be easy in the old xml config style. Not sure what else to do since the reference doc doesn't mention much either.

    Thanks,
    -Z

  • #2
    The value element of the @RequestMapping takes a String[] so I guess you could make it into one @RequestMapping.

    Code:
    @RequestMapping({"/foo", "/bar"})

    Comment


    • #3
      Yep, that worked. Thank you Marten!

      Comment

      Working...
      X