使用springMVC完成多主题切换功能
1.springMVC.xml
<!-- theme解析器 -->
<bean id="themeChangeInterceptor"
class="org.springframework.web.servlet.theme.ThemeChangeInterceptor">
<property name="paramName" value="themeName"></property>
</bean>
<bean id="themeSource"
class="org.springframework.ui.context.support.ResourceBundleThemeSource">
<property name="basenamePrefix" value="themes."></property>
</bean>
<bean id="themeResolver"
class="org.springframework.web.servlet.theme.CookieThemeResolver">
<property name="defaultThemeName" value="style_default" />
</bean>
拦截器
<mvc:interceptors>
<mvc:interceptor>
<mvc:mapping path="/**" />
<ref bean="themeChangeInterceptor" />
</mvc:interceptor>
</mvc:interceptors>
2.项目结构
3.页面标签
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<link href="<%=basePath %><spring:theme code='styleSheet'/>" rel="stylesheet" type="text/css" />
4.style.properties文件
styleSheet=common/css/style2.css
homeTreetableLayout=common/js/treetable/home_treetablelayout.css
homeTreetable=common/js/treetable/home_treetable.css
card_img_play=common/images/default/card_playorpause.png
card_detail_deviceimp=common/images/default/card_redimp.png
card_detail_managerimp=common/images/default/card_yellowimp.png
card_detail_policename=common/images/default/card_police.png
card_detail_publicsecurity=common/images/default/card_publicsecurity.png
card_detail_devicecode=common/images/default/card_device.png
card_detail_datetime=common/images/default/card_time.png