SAR-303 xml validator驗證框架

隨風而逝,只是飄零發表於2016-08-25

// 配置檔案詳解

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

相關文章