spring-servlet.xml setting up theme beans:
<bean id="themeSource"
class="org.springframework.ui.context.support.ResourceBundleThemeSource">
<property name="basenamePrefix" value="theme-" /> // also tried WEB-INF.resources.theme- and WEB-INF/resources/theme- here, same problem
</bean>
<bean id="themeChangeInterceptor"
class="org.springframework.web.servlet.theme.ThemeChangeInterceptor">
<property name="paramName" value="theme" />
</bean>
<bean id="themeResolver"
class="org.springframework.web.servlet.theme.CookieThemeResolver">
<property name="defaultThemeName" value="default" />
</bean>
<bean id="handlerMapping"
class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
<property name="interceptors">
<list>
<ref bean="localeChangeInterceptor" />
<ref bean="themeChangeInterceptor" />
</list>
</property>
</bean>
under WEB-INF/resources, where are 3 theme files:
- theme-black.properties
- theme-blue.properties
- theme-default.properties
each file contain this accordingly:
css=themes/black.css
css=themes/blue.css
css=themes/default.css
i have folder WEB-INF/themes , which contains 3 of these css files, i think the content of css isn't important here.
now error i run into is :
javax.servlet.ServletException: javax.servlet.jsp.JspTagException: Theme 'default': No message found under code 'css' for locale 'en'.
so basically it just can't find the css value f开发者_高级运维or themes, which means it can't find the properties file...
what I am doing wrong? feel free to ask questions
You should try to put theme properties into classpath (as is written in docs). Classpath is not /WEB-INF folder. See this question for clarity.
By default the delegate will be a org.springframework.ui.context.support.ResourceBundleThemeSource that loads properties files from the root of the classpath.
If you do don't want to put the theme.properties file under "classes" folder, you can put it under "META-INF" folder. If you use maven to create and manage the project, the "META-INF" folder is also unser the class path.
For example, if you put the themes under "META-INF/theme", you can do the following stuff to make it works.
<!-- resolves localized <theme_name>.properties files in the classpath to allow for theme support -->
<bean class="org.springframework.ui.context.support.ResourceBundleThemeSource" id="themeSource">
<property name="basenamePrefix" value="META-INF.theme."/>
</bean>
here the problem is not with css file actually ResourcebundleThemeSource trying to find theme-default.properties file in rot of classpath .ie. under the src folder. so put your all properties file under thier, and i am sure your problem will resolve.
Are you trying to use the i18N features in your application , regarding the localization if yes, then you need to add the below code
<"bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
<property name="basename" value="/WEB-INF/messages" />
<property name="cacheSeconds" value="3000" />
</bean>
Otherwise remove your code <ref bean="localeChangeInterceptor" />
from the below code
<bean id="handlerMapping"
class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping">
<property name="interceptors">
<list>
<ref bean="localeChangeInterceptor" />
<ref bean="themeChangeInterceptor" />
</list>
</property>
</bean>
I hope this code will work properly.....
精彩评论