【发布时间】:2014-04-17 21:30:57
【问题描述】:
Spring 控制器是否可以同时处理这两种请求?
1)http://localhost:8080/submit/id/ID123432?logout=true
2)http://localhost:8080/submit/id/ID123432?name=sam&password=543432
如果我定义一个这样的控制器:
@RequestMapping (value = "/submit/id/{id}", method = RequestMethod.GET,
produces="text/xml")
public String showLoginWindow(@PathVariable("id") String id,
@RequestParam(value = "logout", required = false) String logout,
@RequestParam("name") String username,
@RequestParam("password") String password,
@ModelAttribute("submitModel") SubmitModel model,
BindingResult errors) throws LoginException {...}
不接受带有“注销”的 HTTP 请求。
如果我定义两个控制器来分别处理每个请求,Spring 会报错“已经有 'Controller' bean 方法 ... 映射”。
【问题讨论】:
-
阅读这篇文章:codeflex.co/…
标签: java spring spring-mvc