Announcement Announcement Module
Collapse
No announcement yet.
Spring MVC theme and locale error. Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring MVC theme and locale error.

    Hello. I am developing my first Spring project and I have some trouble.
    I use Spring Tool Suite and standart Tomcat server.
    I need two languages and two themes at my site. I do it this way

    part of servlet-context.xml
    Code:
    <interceptors>          
            <beans:bean id="localeChangeInterceptor" class="org.springframework.web.servlet.i18n.LocaleChangeInterceptor">  
                <beans:property name="paramName" value="lang" />  
            </beans:bean>
            <beans:bean class="org.springframework.web.servlet.theme.ThemeChangeInterceptor">   
                <beans:property name="paramName" value="theme" />
            </beans:bean>  
        </interceptors> 
    	
    	<beans:bean id="messageSource"  
            class="org.springframework.context.support.ReloadableResourceBundleMessageSource">  
            <beans:property name="basename" value="classpath:messages" />  
            <beans:property name="defaultEncoding" value="UTF-8" />  
        </beans:bean>   
      
        <beans:bean id="localeResolver"  
            class="org.springframework.web.servlet.i18n.CookieLocaleResolver" p:cookieName="localeResolver">  
            <beans:property name="defaultLocale" value="ru" />  
        </beans:bean>   
        
        <beans:bean class="org.springframework.ui.context.support.ResourceBundleThemeSource"
            id="themeSource"
            p:basenamePrefix="theme-" />
        
        <beans:bean class="org.springframework.web.servlet.theme.CookieThemeResolver"
            id="themeResolver"
            p:cookieName="themeResolver"
            p:defaultThemeName="standard" /
    Here is one of theme-properties file (theme-standart.properties)
    Code:
    styleSheet=resources/css/bootstrap.css
    one of messages-properties file (messages_en.properties)
    Code:
    login.welcome=Welcome!
    login.login=Login
    login.password=Password
    login.signIn=Sign in
    login.error=Invalid login or password!
    login.registration=Registration
    login.return=Come again
    
    header.settings.en=English
    header.settings.sp=Spain
    header.settings.dark=Dark
    header.settings.light=Light
    And my error and the most mysterious thing
    Code:
    javax.servlet.jsp.JspTagException: Theme 'standard': No message found under code 'styleSheet' for locale 'en'
    This error appears when I try open page at first time. I can add "?theme=dark" to the address line by myself and all will be fine and will work perfect(because theme-cookie will create).
    But why and how are theme and locale connected? And how can I fix or avoid this error?
Working...
X