【发布时间】:2012-03-03 04:30:56
【问题描述】:
我在这里尝试了答案中的步骤:Hibernate Validator, custom ResourceBundleLocator and Spring
但仍然只是将{location.title.notEmpty} 作为输出而不是消息。
调度程序-servlet.xml
<bean name="validator"
class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean">
<property name="validationMessageSource">
<ref bean="resourceBundleLocator"/>
</property>
</bean>
<bean name="resourceBundleLocator" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basenames">
<list>
<value>/WEB-INF/validationMessages</value>
</list>
</property>
</bean>
/WEB-INF/validationMessages.properties:
location.title.notEmpty=My custom message
表格(班级位置)
@NotEmpty( message = "{location.title.notEmpty}" )
private String title;
这里出了什么问题?
【问题讨论】:
-
我不知道这是否会导致该问题,但请确保消息属性文件的最后一行有一个空行。
-
不,这不是问题,不需要最后一个空行
标签: hibernate spring spring-3 hibernate-validator