Spring MVC multiple url mapping to the same controller method

Viewed 15081

Let's say we have 3 url-patterns for a servlet named dispatcher in web.xml:

<servlet-mapping>
    <servlet-name>dispatcher</servlet-name>
    <url-pattern>/aaa/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
    <servlet-name>dispatcher</servlet-name>
    <url-pattern>/bbb/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
    <servlet-name>dispatcher</servlet-name>
    <url-pattern>/ccc/*</url-pattern>
</servlet-mapping>

and a controller method:

@RequestMapping(value = "/xxx", method = RequestMethod.POST)
public String foo() {}

Since the path value in @RequestMapping does not contain servlet path, when users request

/aaa/xxx
/bbb/xxx
/ccc/xxx

the requests will all be mapped to method foo.

I think this could cause potential problem if the web site is very complicated. Is it a flaw in Spring Web MVC or I misunderstand something?

2 Answers
Related