exception handling - How to Handle Redirect Flow in Spring Controller -


i new spring , need little guidance. have through spring tutorials, cannot find looking for. want know best way handle scenario:

  1. user goes index page , presented form.
  2. user fills out forms , submits new url (passes client side validation)
  3. during spring validation of form object, detect errors
  4. redirect user index page affected fields highlighted

i assuming correct flow situation. if not, please tell me otherwise. if correct flow, how pass binding/validation errors template?

in situation follow post/redirect/get pattern flow. when server side validation fails (result.haserrors()) not redirect display index page again. spring handles passing errors template. display errors use function of template engine supports spring mvc (for example display errors in jsp - <form:errors path="*" element="div" />).

@controller public class mycontroller {      @requestmapping(value="/index.html", method=requestmethod.get)     public string display(@modelattribute myform myform){         return "index";     }      @requestmapping(value="/process.do", method=requestmethod.post)     public string processform(@modelattribute @validated myform myform,                            bindingresult result) {          if(result.haserrors()){             return display(myform);         }          return "redirect:/processed.html";     } }