zoukankan      html  css  js  c++  java
  • spring validation JSR303 配置

        <!-- Validator -->
        <bean id="validator"
            class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean">
            <property name="providerClass" value="org.hibernate.validator.HibernateValidator" />
            <!-- 如果不加默认到 使用classpath下的 ValidationMessages.properties -->
            <property name="validationMessageSource" ref="messageSource" />
        </bean>
    
        <!-- 国际化的消息资源文件(本系统中主要用于显示/错误消息定制) -->
        <bean id="messageSource"
            class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
            <property name="basenames">
                <list>
                    <!-- 在web环境中一定要定位到classpath 否则默认到当前web应用下找 -->
                    <value>classpath:messages</value>
                    <value>classpath:org/hibernate/validator/ValidationMessages</value>
                </list>
            </property>
            <property name="useCodeAsDefaultMessage" value="false" />
            <property name="defaultEncoding" value="UTF-8" />
            <property name="cacheSeconds" value="60" />
        </bean>

      <bean id="conversionService" class="org.springframework.format.support.FormattingConversionServiceFactoryBean" />

    <bean id="webBindingInitializer" class="org.springframework.web.bind.support.ConfigurableWebBindingInitializer"> <property name="conversionService" ref="conversionService" /> <property name="validator" ref="validator" /> </bean>
      <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">     <property name="webBindingInitializer" ref="webBindingInitializer" />   </bean>
  • 相关阅读:
    [LeetCode] Sort Colors
    [LeetCode] Trapping Rain Water
    [LeetCode] Sudoku Solver
    [LeetCode] Valid Sudoku
    [LeetCode] Candy
    [LeetCode] Permutation Sequence
    [名词解释]Constant Amortized Time
    回溯法 子集树和排序树
    HDU 4859 海岸线 最小割
    敏捷开发一千零一问:怎样处理重要但不明白的任务?
  • 原文地址:https://www.cnblogs.com/longzhaoyu/p/4921475.html
Copyright © 2011-2022 走看看