Spring 3 web request interceptor - how do I get BindingResult?

旧街凉风 提交于 2019-12-01 20:21:18

After execution of controller method BindingResult is stored as a model attribute named BindingResult.MODEL_KEY_PREFIX + <name of the model attribute>, later model attributes are merged into request attributes. So, before merging you can use Hurda's own answer, after merging use:

request.getAttribute(BindingResult.MODEL_KEY_PREFIX + "solicitation")

So with big help from @Axtavt I came to conlusion, that you can get to Bind reuslt from ModelAndView in postHandle method:

void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) {
  String key = BindingResult.MODEL_KEY_PREFIX + "commandName";
  BindingResult br = (BindingResult) modelAndView.getModel().get(key);
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!