无法解决,资源文件UTF-8,freemarker 编码UTF-8。

资源文件名: ValidationMessages_zh_CN.properties

内容:

mobile.empty=手机号必填
userId.empty=请输入用户Id
userName.empty=请输入用户名
password.empty=请输入密码

ascii2native后不识别资源内容

加上:

<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="useCodeAsDefaultMessage" value="false"/>
<property name="defaultEncoding" value="UTF-8"/>
<property name="fallbackToSystemLocale" value="true"/>
<property name="cacheSeconds" value="60" />
<property name="basenames">
<list>
<value>classpath:ValidationMessages</value>
</list>
</property>
</bean>
<bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean">
<property name="providerClass" value="org.hibernate.validator.HibernateValidator"/>
<property name="validationMessageSource" ref="messageSource"/>
</bean>

依然无效,此问题待解决!

update:

经过几番折腾,发现没有配置下面这行

<mvc:annotation-driven validator="validator"/>

配置后,生效!

Leave a reply

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> 

required

− two = one