What is the use of BindingResult interface in spring MVC?

前端 未结 6 1067
梦如初夏
梦如初夏 2020-12-12 18:43

Is BindingResult useful to bind just exceptions with view, or something else?

what is the exact use of BindingResult?

Or is it usef

6条回答
  •  -上瘾入骨i
    2020-12-12 19:23

    BindingResult is used for validation..

    Example:-

     public @ResponseBody String nutzer(@ModelAttribute(value="nutzer") Nutzer nutzer, BindingResult ergebnis){
            String ergebnisText;
            if(!ergebnis.hasErrors()){
                nutzerList.add(nutzer);
                ergebnisText = "Anzahl: " + nutzerList.size();
            }else{
                ergebnisText = "Error!!!!!!!!!!!";
            }
            return ergebnisText;
        }
    

提交回复
热议问题