23 Mart 2018 Cuma

SpringMVC BindingResult Arayüzü

hasErrors metodu
Şöyle yaparız.
@PostMapping
public String doAction(@Valid @ModelAttribute("myModel") MyModel myModel,
                      BindingResult bindingResult,
                      RedirectAttributes redirectAttrs) throws Exception {
  if (bindingResult.hasErrors()) {
    return "thepage";
  }
  // service logic
  redirectAttrs.addFlashAttribute("success", "My Model was added successfully");
  return "redirect:/thepage";
}

Hiç yorum yok:

Yorum Gönder