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

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -