spring - Tomcat Show HTTP Status 400 Error Page During Validation -


i'm learning make bean validation works in spring mvc thymeleaf default view. every valid data can saved properly. when tried invalid data passed, tomcat showed http status 400 error page. in tomcat console showed validation became logging text in tomcat console. here controller saves data (item).

@controller @requestmapping("/item") @sessionattributes("item") public class itemcontroller {     @autowired     private itemservice itemservice;     @autowired     private colorservice colorservice;      @modelattribute("allcolors")     public list<color> populatecolors() {         return colorservice.findall();     }      @modelattribute("allitems")     public list<item> populateitems() {         return itemservice.findall();     }      @requestmapping(value = {"/image/{id}", "image/{id}"})     @responsebody     public byte[] showimage(@pathvariable("id") string id) {          return itemservice.getitem(id).getimage();     }      @requestmapping(value = {"", "/"}, method = requestmethod.get)     public string showallitems() {          return "itemlist";     }      @requestmapping(value = {"add", "/add"}, method = requestmethod.get)     public string showitemaddform(model model) {         model.addattribute("item", new item());          return "itemaddform";     }      @requestmapping(value = {"add", "/add"}, method = requestmethod.post)     public string processadditem(             @modelattribute("item") @valid item item,             redirectattributes model,             bindingresult errors,             sessionstatus session) {         if (errors.haserrors()) {             return "itemaddform";         }          itemservice.saveitem(item);         session.setcomplete();          model.addflashattribute("message", "item has been added");         return "redirect:/item";         }     } 

is wrong controller? how should make bean validation works spring , thymeleaf?


Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -