【问题标题】:Spring Web MVC: Internationalization/Localization : No message foundSpring Web MVC:国际化/本地化:未找到消息
【发布时间】:2015-08-21 15:20:52
【问题描述】:

我似乎找不到国际化的来源。 我收到以下错误:

javax.servlet.jsp.JspTagException: No message found under code 'label.firstname' for locale 'en'.

在我的jsp中我这样做:

<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<h1 class="page-header"><spring:message code="label.firstname"/></h1>

在两个 message.properties 中都有一个密钥对:

label.firstname=First Name (messages_en.properties)
label.firstname=Voornaam (messages_nl.properties)

我做错了什么?

【问题讨论】:

    标签: java spring spring-mvc localization internationalization


    【解决方案1】:

    我找到了解决办法。

    属性文件应该在 /WEB-INF/classes 下

    【讨论】:

      【解决方案2】:

      尝试添加更多:

      <bean id="messageSource"
          class="org.springframework.context.support.ResourceBundleMessageSource">
          <property name="basename" value="classpath:messages"/>
      </bean>
      

      您的资源包必须在您的类路径中。

      【讨论】:

      • 我听从了你的建议,但仍然有同样的错误:(
      • 仍然没有用...或者它可能是 Tomcat 特定的错误?
      猜你喜欢
      • 2018-11-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多