What happens: When I put a globalError on the BindingResult (using reject
) it don't appear in my view.
My Controller:
@RequestMapping("register/manageCliente/newcliente.do")
public String newClienteDo(@ModelAttribute("formCliente") @Valid Cliente formCliente, BindingResult bResult, Model model) throws Exception {
if(!bResult.hasErrors()) {
try {
//Do Something
} catch (SQLException e) {
logger.error("No newClienteDo :" + e); //it works, the error appear into my log4j.
bResult.reject(e.getMessage());
}
}
if (bResult.hasErrors() || bResult.hasGlobalErrors()) {
model.addAttribute("msgError",bResult.getAllErrors().toString()); //it works, if I put the model in the view
return "register/manageCliente/newcliente";
}
model.addAttribute("formCliente",formCliente);
return "redirect:/register/manageCliente/listcliente";
}
On my view I put the <form:errors>
on this way:
<form:form action="newcliente.do" method="post" modelAttribute="formCliente" commandName="formCliente">
<form:errors></form:errors>
</form:form>
I tried <form:errors path="*">
and don't work too.
It don't show any errors, I'm using log4j with log4j.logger.org.springframework=DEBUG
active. It don't show any errors too.
Thank you,
Edited.
It is doing about 4 requests to the view, ever cleaning my rejects. I tried the solution with Post-Redirect-Get and don't work too.
Edited.2
Since its was an emergencial problem I put the errors on a model.addAttribute
and print the errors with EL in my view. But its not correct, so if someone has a better solutions I'll keep this post opened.