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
Post a Comment