spring mvc - Issue with RedirectAttributes on SpringMVC -


i'm having issue redirectattributes not saving (i think). code:

@requestmapping(path = "/job_offers", method = requestmethod.post)     public string createjoboffer(@valid @modelattribute("jobofferform") jobofferform jobofferform,             final bindingresult binding, redirectattributes attr) {         attr.addflashattribute("org.springframework.validation.bindingresult.jobofferform", binding);         attr.addflashattribute("jobofferform", jobofferform);          return "redirect:/job_offers";     }  @requestmapping(path = "/job_offers", method = requestmethod.get)     public modelandview joboffers(@requestparam(required = false, value = "skill_id") final long skillid,             @modelattribute("jobofferform") jobofferform jobofferform, final bindingresult binding) {          modelandview mav = new modelandview("job_offers/index");          mav.addallobjects(getjoboffersmap(skillid));         mav.addobject("jobofferform", jobofferform);          return mav;     } 

if print binding in post method has error in it, when call method via redirect binding comes empty! , spring doesnt show error feedback on forms because of that

any ideas? thanks!

try this: in post

 attr.addflashattribute("bindignresultforjobofferform", binding); 

and in get

if (model.asmap().containskey("bindignresultforjobofferform"))     {         model.addattribute("errors",                 model.asmap().get("bindignresultforjobofferform"));     } 

Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -

java - Digest auth with Spring Security using javaconfig -