Spring MVC: How to redirect to a page with error?

后端 未结 2 566
我在风中等你
我在风中等你 2021-01-15 10:32

I am trying to make my Controller to redirect to a page with a custom error message:

    @RequestMapping(method=RequestMethod.POST)
    public String process         


        
2条回答
  •  星月不相逢
    2021-01-15 10:59

    There's something wrong in your controller method. It would be better way to call getAllErrors() method from result than the getFieldErrors(). Of course if the result is BindingResult type . Like this:

    model.addAttribute("errors", result.getAllErrors());

提交回复
热议问题