0

I have this form which i post to spring and I am trying to make it display the original value from the database before i posted the updated value whilst leaving the error message on the field if there is a validation error not the posted value. However nothing i do seems to work.

My post action looks like:

@RequestMapping(method=RequestMethod.POST)
public String updateValues(@ModelAttribute("values") @Valid ValueList, Errors errors, RedircetAttributes redirectAttributes){

     if (errors.hasErrors()){
        return VALUES_VIEW;
     }
     //Do update stuff
     return VALUES_REDIRECT;
}
4

1 に答える 1

0

モデルに入っている値を DB からの値に上書きします。あなたの場合、次のようなものです:

ValueList dbValueList = someService.getValueList();
valueListInModel.setSomeProperty(dbValueList.getSomeProperty());
于 2012-07-09T13:46:11.073 に答える