zoukankan      html  css  js  c++  java
  • hibernate validator配置国际化支持时直接输出键值

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
    http://www.springframework.org/schema/mvc
    http://www.springframework.org/schema/mvc/spring-mvc-4.1.xsd">
    
        <mvc:interceptors>
            <bean id="localeChangeInterceptor" class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">
                <property name="paramName" value="lang"/>
            </bean>
        </mvc:interceptors>
    
    
        <bean id="localeResolver" class="org.springframework.web.servlet.i18n.CookieLocaleResolver">
            <property name="cookieMaxAge" value="604800"/>
            <property name="defaultLocale" value="zh_CN" />
            <property name="cookieName" value="language"></property>
        </bean>
    
        <bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
            <property name="basenames">
                <list>
                    <value>classpath:i18N/messages</value>
                    <value>classpath:i18N/validation</value>
                </list>
            </property>
               <property name="defaultEncoding" value="UTF-8" />
            <property name="useCodeAsDefaultMessage" value="false"/>
        </bean>
    
        <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>
    </beans>




    https://www.oschina.net/question/1243908_2146076
  • 相关阅读:
    python开发必备:virtualenv虚拟环境(自用)
    JavaScript经典实例
    javascript事件驱动及事件处理
    在HTML网页中嵌入脚本的方式
    JavaScript数据结构
    JavaScript语言调试技巧
    CSS+DIV布局
    在HTML文档中应用CSS
    CSS常用属性
    定义CSS
  • 原文地址:https://www.cnblogs.com/lizhonghua34/p/12169743.html
Copyright © 2011-2022 走看看