model view controller - Spring CRUD - update with @ModelAttribute -
i have update method in controller:
@requestmapping(value = constants.update, method = requestmethod.post) public modelandview updateproduct(@modelattribute("productmodel") productmodel productmodel) { productservice.updateproduct(productmodel); modelandview modelandview = new modelandview("redirect:/showproducts"); return modelandview; }
the problem when i'm doing update in form, of fields has submitted, if leave field empty - error - request sent client syntactically incorrect. best way make possible update single column without getting error? productmodel rather simple have productname, description , price , query in dao is:
string sql = "update product set description=?, productname=?, price=? id=?";
the simplest way read product fields database before updating, overwrite ones received form, , update fields.
Comments
Post a Comment