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>
  • 相关阅读:
    线程
    ACM/OJ输入输出Tips
    Maven---pom.xml详解
    通过chrome分析知乎的登录过程学习cookie原理
    Javaweb日志系统
    SpingMVC+AJAX+jquery表单数据交互
    SpringMVC Controller 失效 404错误 IEDA
    【JavaSE】Properties类
    freemaker判断对象非空
    移植openssh时could not load host key: /etc/ssh/ssh_host_rsa_key 无法启动ssh的一个解决办法
  • 原文地址:https://www.cnblogs.com/longzhaoyu/p/4921475.html
Copyright © 2011-2022 走看看