如何根据我的语言正确获取消息验证消息,作为回报,我得到的是默认休眠验证器,但不是注释 @NotEmpt 中定义的消息。
@Entity
public class News {
@Id
private Integer idNews;
@NotEmpty(message = "{news.title.error}")
@Column
private String title;
........
}
在我的配置中:
<!-- locale change using a cookie -->
<bean id="localeResolver" class="org.springframework.web.servlet.i18n.CookieLocaleResolver" >
<property name="defaultLocale" value="pt" />
</bean>
<!-- Access resource bundles with the specified basename -->
<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basenames">
<list>
<value>/WEB-INF/i18n/messages</value>
<value>/WEB-INF/i18n/validation</value>
</list>
</property>
</bean>
<!-- JSR-303 -->
<bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean">
<property name="validationMessageSource" ref="messageSource"/>
</bean>