I'm trying to implement form validation with Spring Validator, following these tutorials from dzone and mkyong.
It seems the Validator method validate is called upon form submission, errors are thrown, but the message codes aren't the same that I specified.
I have a bean named Song with an attribute name title
In my Validator, I have
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "title", "title.required");
yet, I got this error message
org.springframework.context.NoSuchMessageException: No message found under code 'title.required.song.title' for locale 'en_US'.
it searches the message under title.required.song.title instead of title.required, and I guess under a file name messages_en_US.properties
How can I change this behaviour?
My messages.properties placed under /src/
folder has
title.required=Ce champ est obligatoire
@Entity
public class Song {
@Id
@GeneratedValue
private Long id;
private String title;
//and other stuff