I am new to spring. I am currently creating a news manager form.
Here is an example of my news object:
class News { @NotNull long id; @NotNull long idAuthor; @Size(max=255) String content; }
As you can see, I am using JSR303 annotation check with Spring. I want to confirm my "news editing form".
@RequestMapping( value = "/edit" , method = RequestMethod.POST) public String editAction(@Valid @ModelAttribute News news, BindingResult result) { System.err.println(result.hasErrors()); ... return "editView"; }
Define a valid field:
//initBinder function : binder.setAllowedFields("content");
Well, I'm trying to check only the "content" field (a valid field is set on my insert) ... But spring always checks the entire field defined on my entity (so that "id" and "idAuthor" return an error)
How can I check a valid field (set in the initBinder function)?
source share