Announcement Announcement Module
No announcement yet.
About annotations controller Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • About annotations controller

    hi,all ,im new to spring annotations and mvc,here is my problem
    i hava a simple controller like this:

    public User getUser(@RequestParams("userId")int id){
    //load user from DB
    return userDao.getUser(id);

    @RequestMapping(value="/update.html", method=RequestMethod.POST)
    public ModelAndView editUser(@ModelAttribute("user")User user, BindingResult result){

    //some logic validation
    ...result.rejectValue("age","age too young");

    return new ModelAndView("...");

    i found that user object which loaded from db(persist object) is always updated(saved) when form submit(means hibernate transaction.commit(),and object was "flush" into db), although there were some errors in bindingResult.

    i remeber in simpleFormController ,i can use onbind() or onBindAndValidate()
    to validate data input and "stop" update/save object and return to form view with error data, but here i couldnt stop hibernate flush cache to update the user object, BindingResult or Errors seems not working for me,can it stop form submission or transaction.commit()??or is there some other way to do this?

    thanks for help