title: Struts 1 + Spring 3 Language and Theme Support + Tiles
body: <p>I am working on an old Struts 1 application. I have tried to add Theme and Internationalization (i18n) / Localization (L10n) support from Spring 3 MVC.</p>
  
  <p>This is the code:
  web.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;web-app id="WebApp_ID" version="2.5"
  xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"&gt;
  
  &lt;!-- Struts Configuration --&gt;
  &lt;servlet&gt;
      &lt;servlet-name&gt;action&lt;/servlet-name&gt;
      &lt;servlet-class&gt;
          org.apache.struts.action.ActionServlet
      &lt;/servlet-class&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;config&lt;/param-name&gt;
          &lt;param-value&gt;/WEB-INF/struts-config.xml&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;debug&lt;/param-name&gt;
          &lt;param-value&gt;2&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;detail&lt;/param-name&gt;
          &lt;param-value&gt;2&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;validate&lt;/param-name&gt;
          &lt;param-value&gt;true&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;autowire&lt;/param-name&gt;
          &lt;param-value&gt;byName&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
  &lt;/servlet&gt;
  
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;action&lt;/servlet-name&gt;
      &lt;url-pattern&gt;*.do&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  &lt;!-- Struts Configuration --&gt;
  
  &lt;!-- The definition of the Root Spring Container shared by all Servlets and Filters --&gt;
  &lt;context-param&gt;
      &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
      &lt;param-value&gt;/WEB-INF/dispatcher-servlet.xml&lt;/param-value&gt;
  &lt;/context-param&gt;
  
  &lt;listener&gt;
      &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
  &lt;/listener&gt;
  
  &lt;!-- The definition of the Root Spring Container shared by all Servlets and Filters --&gt;
  
  &lt;!-- welcome file list --&gt;
  &lt;welcome-file-list&gt;
      &lt;welcome-file&gt;welcome.do?method=test&lt;/welcome-file&gt;
  &lt;/welcome-file-list&gt;
  &lt;!-- welcome file list --&gt;
  
  &lt;!-- tld configuration --&gt;
  &lt;jsp-config&gt;
      &lt;taglib&gt;
          &lt;taglib-uri&gt;/WEB-INF/struts-bean.tld&lt;/taglib-uri&gt;
          &lt;taglib-location&gt;/WEB-INF/struts-bean.tld&lt;/taglib-location&gt;
      &lt;/taglib&gt;
      &lt;taglib&gt;
          &lt;taglib-uri&gt;/WEB-INF/struts-html.tld&lt;/taglib-uri&gt;
          &lt;taglib-location&gt;/WEB-INF/struts-html.tld&lt;/taglib-location&gt;
      &lt;/taglib&gt;
      &lt;taglib&gt;
          &lt;taglib-uri&gt;/WEB-INF/struts-logic.tld&lt;/taglib-uri&gt;
          &lt;taglib-location&gt;/WEB-INF/struts-logic.tld&lt;/taglib-location&gt;
      &lt;/taglib&gt;
      &lt;taglib&gt;
          &lt;taglib-uri&gt;/WEB-INF/struts-nested.tld&lt;/taglib-uri&gt;
          &lt;taglib-location&gt;/WEB-INF/struts-nested.tld&lt;/taglib-location&gt;
      &lt;/taglib&gt;
      &lt;taglib&gt;
          &lt;taglib-uri&gt;/WEB-INF/struts-template.tld&lt;/taglib-uri&gt;
          &lt;taglib-location&gt;/WEB-INF/struts-template.tld&lt;/taglib-location&gt;
      &lt;/taglib&gt;
      &lt;taglib&gt;
          &lt;taglib-uri&gt;/WEB-INF/struts-tiles.tld&lt;/taglib-uri&gt;
          &lt;taglib-location&gt;/WEB-INF/struts-tiles.tld&lt;/taglib-location&gt;
      &lt;/taglib&gt;
  &lt;/jsp-config&gt;
  &lt;!-- tld configuration --&gt;
  </code></pre>
  
  <p></p>
  
  <p>struts-config.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="ISO-8859-1" ?&gt;&lt;!DOCTYPE struts-config PUBLIC
  "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
  "/WEB-INF/tiles-config.dtd"&gt;&lt;struts-config&gt;
  &lt;form-beans&gt;
  &lt;form-bean name="myForm" type="forms.myForm" /&gt;
  &lt;/form-beans&gt;
  
  &lt;action-mappings&gt;
  &lt;action name="myForm" type="actions.myFormAction"
          path="/welcome" scope="request" parameter="method"&gt;
          &lt;forward name="signin" path="welcome" /&gt;
      &lt;/action&gt;&lt;/action-mappings&gt;
  
  &lt;controller&gt;
      &lt;set-property property="processorClass"
          value="actions.CustomRequestProcessor" /&gt;
  &lt;/controller&gt;
  
  &lt;plug-in className="org.apache.struts.tiles.TilesPlugin"&gt;
      &lt;set-property property="definitions-config" value="/WEB-INF/tiles-defs.xml" /&gt;
      &lt;set-property property="moduleAware" value="true" /&gt;
  &lt;/plug-in&gt;
  
  &lt;plug-in className="org.springframework.web.struts.ContextLoaderPlugIn"&gt;
      &lt;set-property property="contextConfigLocation"
          value="/WEB-INF/dispatcher-servlet.xml" /&gt;
  &lt;/plug-in&gt;
  </code></pre>
  
  <p></p>
  
  <p>dispatcher-servlet.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;&lt;beans xmlns="http://www.springframework.org/schema/beans"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
  xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:context="http://www.springframework.org/schema/context"
  xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"&gt;
  &lt;bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource"&gt;
      &lt;!--  &lt;property name="basename" value="classpath:messages" /&gt; --&gt;
      &lt;property name="basename" value="/WEB-INF/classes/resources/Applicationresource" /&gt;
      &lt;property name="defaultEncoding" value="UTF-8"/&gt;
      &lt;property name="cacheSeconds" value="5"/&gt;
      &lt;property name="UseCodeAsDefaultMessage" value="true"/&gt;
  &lt;/bean&gt;
  
  &lt;!-- Locale Change Intercepter and Resolver definition --&gt;
  &lt;bean id="localeResolver"
      class="org.springframework.web.servlet.i18n.SessionLocaleResolver"&gt;
      &lt;property name="defaultLocale" value="en" /&gt;
  &lt;/bean&gt;
  
  
  &lt;bean id="themeSource"
      class="org.springframework.ui.context.support.ResourceBundleThemeSource"&gt;
      &lt;property name="basenamePrefix" value="theme-" /&gt;
  &lt;/bean&gt;
  
  &lt;!-- Theme Change Intercepter and Resolver definition --&gt;
  &lt;bean id="themeResolver"
      class="org.springframework.web.servlet.theme.CookieThemeResolver"&gt;
      &lt;property name="defaultThemeName" value="default" /&gt;
  &lt;/bean&gt;
  
  &lt;mvc:interceptors&gt;
      &lt;bean id="themeChangeInterceptor"
          class="org.springframework.web.servlet.theme.ThemeChangeInterceptor"&gt;
          &lt;property name="paramName" value="theme" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="localeChangeInterceptor"
          class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor"&gt;
          &lt;property name="paramName" value="language" /&gt;
      &lt;/bean&gt;
  
      &lt;bean id="themeAndLanguageInterceptor"
          class="common.interceptor.ThemeAndLanguageInterceptor"&gt;
          &lt;property name="paramName" value="LUSSI" /&gt;
      &lt;/bean&gt;
      &lt;bean id="handlerInterceptorclass" class="common.interceptor.HandlerInterceptor"&gt;
          &lt;property name="themParamName" value="theme" /&gt;
          &lt;property name="languagParamName" value="language" /&gt;
      &lt;/bean&gt;
  
  &lt;/mvc:interceptors&gt;
  </code></pre>
  
  <p></p>
  
  <p>tiles-defs.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE tiles-definitions PUBLIC "-//Apache Software Foundation//DTD Tiles Configuration 1.1//EN" "/WEB-INF/tiles-config.dtd"&gt;
  &lt;tiles-definitions&gt;
  &lt;definition name="base.definition1" template="/WEB-INF/jsp/layout1.jsp"&gt;
  &lt;put name="body" value="" /&gt;
  &lt;/definition&gt;
  &lt;definition name="welcome" extends="base.definition1"&gt;
  &lt;put name="title" value="Home" /&gt;
  &lt;put name="body" value="/home.jsp" /&gt;
  &lt;/definition&gt;
  &lt;/tiles-definitions&gt;
  </code></pre>
  
  <p>home.jsp</p>
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%&gt;
  &lt;%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%&gt;
  &lt;%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %&gt;
  &lt;%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %&gt;
  &lt;%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %&gt;
  &lt;html&gt;
  &lt;head&gt;&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /&gt;
  &lt;title&gt;Home&lt;/title&gt;
  &lt;link rel="stylesheet" type="text/css" href="&lt;spring:theme code='css'/&gt;" /&gt;
  </code></pre>
  
  <p>But when I run the application, I get the following error:</p>
  
  <pre><code>javax.servlet.jsp.JspTagException: Theme 'theme': No message found under code 'css' for locale 'en_IN'.
  </code></pre>
  
  <p>Does someone know how to solve it? Thanks in advance.</p>