JSF 2.0, Bean Validation and labels
问题 How can I show the field label in a JSF error message when bean validation is used? <h:messages/> <h:inputText label="Username" value="#{myBean.username}" /> ... public class MyBean { @NotNull private String username; ... } If no user name is submitted only "Must not be null" is shown and there is no field reference. 回答1: To display the concerned component's label in the error message define a new value for the property javax.faces.validator.BeanValidator.MESSAGE in a resource bundle of the