在同一个控制器处理程序方法中,我想要:
Spring MVC可以实现吗?
答案 0 :(得分:1)
是的可能。
@RequestMapping(value = "/show", method = RequestMethod.GET)
public String show(ModelMap model,
HttpServletRequest request,
HttpServletResponse response) {
if (isValidAsYouWant(request)) { // check validity
// setup reference data
return "viewName";
} else {
response.setStatus(400);
try {
response.getWriter().write("Invalid Request");
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
}