Quantcast
Viewing all articles
Browse latest Browse all 34

Spring MVC Validate form and return data if has errors

I can successfully validate my form and even return the errors. My problems started when my view had a few selects that needed to be populated with the data coming from the controller.

When i do model.addAttribute(...) it stops passing the errors to the view:

 public String registerSubmit(@Valid @ModelAttribute("jconcorrente") Jconcorrentes concorrente, BindingResult result, HttpServletRequest request, Model model){         if(result.hasErrors()) {             model.addAttribute("listJdistrito", this.jdistritoService.listJdistrito());             model.addAttribute("listJtipocodiden", this.jtipodocidenService.listJtipodociden());             model.addAttribute("jconcorrente", new Jconcorrentes());                return "register";            }

So my question is how can i pass the data without affecting the validation errors?


Viewing all articles
Browse latest Browse all 34

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>