Spring 3 Web请求拦截器-如何获取BindingResult?

我真的很感谢Spring 3阳极驱动的Web控制器映射

我有很多带有类似签名的控制器:

@RequestMapping(value = "solicitation/create",method = RequestMethod.POST)

public String handleSubmitForm(Model model, @ModelAttribute("solicitation") Solicitation solicitation, BindingResult result)

但是我的问题是,我想编写一个拦截器,该拦截器在处理后会通过BindingResults-如何从HttpRequest或HttpResponse中获取它们?

因为intercpetor方法具有相同的签名

public boolean postHandle(HttpServletRequest request, HttpServletResponse response, Object handler)

回答:

因此,在@Axtavt的大力帮助下,我得出了结论,即可以在postHandle方法中从ModelAndView绑定Bind reuslt:

void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) {

String key = BindingResult.MODEL_KEY_PREFIX + "commandName";

BindingResult br = (BindingResult) modelAndView.getModel().get(key);

}

以上是 Spring 3 Web请求拦截器-如何获取BindingResult? 的全部内容, 来源链接: utcz.com/qa/402833.html

回到顶部