Thursday 15 July 2010

java - Spring loses the BindingResult and don't sent globalErrors to the view -


What happens: When I put a global error on binding result (using reject ). In my opinion

My Controller:

  @RequestMapping ("register / manageCliente / newcliente.do") public string newClienteDo (@ModelAttribute ("formCliente") {Validate Cliente formCliente, BindingResult bResult, model model} are exceptions {throws} {try {// do something} hold (SQLException e) {logger.error ("not newClienteDo:" (bResult.hasErrors (!) + E) ; // This works, error appears in my log4j; bResult.reject (e.getMessage ());}} if (bResult.hasErrors () || bResult.hasGlobalErrors ()) {model.addAttribute (. " MsgError ", bResult.getAllErrors () toString ()); // This works, if I go to the model "Register / Management Client / Nuclealte" in the return of the mine;} Model.addAttribute ("formCliente", formCliente); Return "Redirect: / Register / Management Client / Catalog Client";}  

On my mind, I put & lt; form: errors & gt; in such a way:

  
form: form = "Nucleante Do "method =" post "model attribute =" formclante "commandname =" formclient "& gt; & Lt; Form: Errors & gt; & Lt; / Form: Errors & gt; & Lt; / Form: Form & gt;

I tried & lt; Form: Errors Path = "*" & gt; do not work too much.

It is not showing any error, I am using log4j log4j.logger.org.springframework = DEBUG active it does not show any errors

Thanks,

Edited.

This is about the four requests of the scene, never rejecting me, I tried to work with the post-redirect-gate and did not do too much work.

Edited 2

Since this was an emerging problem, I print errors with a model.addAttribute and EL in my view. But this is not correct, so if there is a better solution then I will keep this post open.


No comments:

Post a Comment