hguser
hguser

Reputation: 36058

how to set multiple pattern for one method in spring mvc controller

In my controller:

@RequestMapping(value = "/", method = RequestMethod.GET)
public String index() {
    return "page/post/list";
}

I want url with pattern '/' or '/list' or '/index' are all handled by this method,is there any way to config it?

Upvotes: 2

Views: 437

Answers (1)

erimerturk
erimerturk

Reputation: 4288

@RequestMapping(value = {"/", "/list", "/index"}, method = RequestMethod.GET)
public String index() {
    return "page/post/list";
}

Upvotes: 3

Related Questions