Max ZooZoo Max ZooZoo - 1 year ago 109
Java Question

Where to put text properties?

I'm trying to do localization for my Java web application and I am getting an error. I am using Maven for dependencies and I am using Google app engine (Jetty web server). The application is using spring framework. Here is what I have so far:

Project structure:

enter image description here

label.firstname=First Name
label.lastname=Last Name


<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib prefix="t" tagdir="/WEB-INF/tags"%>
<%@ taglib prefix="spring" uri=""%>
<jsp:attribute name="title">
<script type="text/javascript" src="../static/js/index.js"></script>
<div class="flex_container_column">
<spring:message code="label.firstname" />
<spring:message code="label.lastname" />


<mvc:resources mapping="/static/**" location="/static/" />
<mvc:annotation-driven />
<bean id="viewResolver"
<property name="viewClass"
value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/WEB-INF/jsp/" />
<property name="suffix" value=".jsp" />

<!-- Resource bundle message: Start -->
<bean id="messageSource"
<property name="basename" value="messages" />
<property name="defaultEncoding" value="UTF-8" />

<bean id="localeChangeInterceptor"
<property name="paramName" value="lang" />

<bean id="localeResolver"
<property name="defaultLocale" value="en" />

<bean id="handlerMapping"
<property name="interceptors">
<ref bean="localeChangeInterceptor" />
<!-- Resource bundle message: End -->


WARNING: Nested in javax.servlet.ServletException: javax.servlet.jsp.JspException: javax.servlet.jsp.JspTagException: No message found under code 'label.firstname' for locale 'en_US'.:
javax.servlet.jsp.JspTagException: No message found under code 'label.firstname' for locale 'en_US'.
at org.springframework.web.servlet.tags.MessageTag.doEndTag(
at org.apache.jsp.index_jsp._jspx_meth_spring_005fmessage_005f0(
at org.apache.jsp.index_jsp.access$0(
at org.apache.jsp.index_jsp$Helper.invoke1(
at org.apache.jsp.index_jsp$Helper.invoke(



I tried few things:

  1. Moved the messages to
    but I got the same error when I changed
    <property name="basename" value="/WEB-INF/messages" />
    . But as per my understanding, if I do so, then I might not be able to access this in the code. That is why I put it into resources initially.

  2. I removed en_US from the default messages property file name, but I got the same error.

Appreciate your help on where and how to setup the project property files + the

Answer Source

I ended up putting the in /WebContent/WEB-INF/messages/ and the reason I was getting the error was because I have 2 contexts defined:

  1. applicationContext.xml
  2. spring-mvc-servlet.xml

I was putting the configuration in spring-mvc-servlet.xml, which was not the right place. Instead, it should have been in applicationContext.xml (the parent context). I solved the issue but then I faced another problem, LocaleChangeInterceptor is not intercepting, so the language can't be changed! However, the problem is resolved.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download