I have strange behavior when I check my form.
As soon as I add the Hibernate @Valid annotation, Tomcat agreed to my request as "bad" if the published data is invalid. If the data is valid, do not worry.
I use:
- Tomcat 7.0.52
- Javax Validation api 1.1.0.Final
- Hibernate Validator 5.1.0.Final
- Spring 4.0.3.RELEASE
At the moment, I am really doing a simple check:
public class RemoveCacheElementForm {
@NotBlank(message = "Please select a cache name.")
private String name;
@NotBlank(message = "Please select a cache entry key.")
private String key;
Spring Controller:
@RequestMapping(value = CACHE_REMOVE, method = RequestMethod.POST)
public String removeCachedElement(ModelMap model, @Valid @ModelAttribute(FORM_NAME) RemoveCacheElementForm form) {
model.addAttribute("removeElementResult", CacheUtils.removeCachedElement(form.getName(), form.getKey()));
initializeModel(model);
return CACHE_ADMIN_PAGE;
}
When I delete the @Valid annotation, don't worry.
Does anyone have an idea?
Many thanks for your help!: -)
source
share