zoukankan      html  css  js  c++  java
  • 解决org.springframework.context.NoSuchMessageException: No message found under code 'login.validate.er

    转自:https://blog.csdn.net/steveguoshao/article/details/36184971

    在项目中遇到

    org.springframework.context.NoSuchMessageException: No message found under code 'login.validate.error' for locale 'zh_CN'.

    搞了半天也没解决,谷歌了看别人也遇到这样的问题,看他是路径问题,当初看别人的时候怎么没有想到呢?结果自己也是路径问题,没有把消息加载进来,

    刚开始的spring配置:

     1     <!-- 国际化的消息资源文件(本系统中主要用于显示/错误消息定制) -->
     2     <bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
     3         <property name="basenames">
     4             <list>
     5                 <!-- 在web环境中一定要定位到classpath 否则默认到当前web应用下找  -->
     6                 <value>classpath:/messages</value>
     7                 <value>classpath:/ValidationMessages</value>
     8             </list>
     9         </property>
    10         <property name="useCodeAsDefaultMessage" value="false"/>
    11         <property name="defaultEncoding" value="UTF-8"/>
    12         <property name="cacheSeconds" value="60"/>
    13     </bean>

    而我message的路径是resources/message/messages.propeties

    当然加载不到了,后来改成:

     1     <!-- 国际化的消息资源文件(本系统中主要用于显示/错误消息定制) -->
     2     <bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
     3         <property name="basenames">
     4             <list>
     5                 <!-- 在web环境中一定要定位到classpath 否则默认到当前web应用下找  -->
     6                 <value>classpath:/messages/messages</value>
     7                 <value>classpath:/messages/ValidationMessages</value>
     8             </list>
     9         </property>
    10         <property name="useCodeAsDefaultMessage" value="false"/>
    11         <property name="defaultEncoding" value="UTF-8"/>
    12         <property name="cacheSeconds" value="60"/>
    13     </bean>
  • 相关阅读:
    Use Module and Function instead of Class in Python
    以命令行方式使用Desktop版Ubuntu
    python中两种拷贝目录方法的比较
    查找重复文件并删除的工具
    Manage sshd Service on CentOS
    Java多线程间的数据共享
    并发 总结
    MapReduce 过程分析
    java能不能自己写一个类叫java.lang.System/String正确答案
    生产者消费者模式--阻塞队列--LOCK,Condition--线程池
  • 原文地址:https://www.cnblogs.com/sharpest/p/5242889.html
Copyright © 2011-2022 走看看