How to optimize my code in Spring MVC Controller using @RequestMapping?

Viewed 1388

In my controller,My controller method names are equals to the requestmapping url.For example,/list is equal to method name list. Is there has a common handler method to short my code?I do not want to write every controller and method in these way.I remember that .net mvc has a comom way to config it.What about Spring MVC?

@Controller
@RequestMapping(value = "/fooController ")
public class FooController {
     @RequestMapping("/list") public String list(...) { ... }
     @RequestMapping("/save") public String save(...) { ... }
     @RequestMapping("/delete") public String delete(...) { ... }
}

@Controller
@RequestMapping(value = "/basketballController ")
public class BasketballController {
     @RequestMapping("/list") public String list(...) { ... }
     @RequestMapping("/save") public String save(...) { ... }
     @RequestMapping("/delete") public String delete(...) { ... }
}
3 Answers
Related