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方法...映射”异常。
2
阅读本文:codeflex.co/…–
—
ybonda