java配置系统全局返回变量(freemarker)
2017-08-31 16:32
218 查看
在spring-mvc.xml中配置(前提是系统用了freemarker)
<bean id="freeMarkerConfigurer"
class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
<property name="templateLoaderPath" value="/WEB-INF/pages/"/>
<property name="defaultEncoding" value="UTF-8"/>
<property name="freemarkerSettings" ref="freemarkerConfiguration"/>
<property name="freemarkerVariables">
<map>
<entry key="shiro" value-ref="shiroTags"/>
<entry key="chatUrl" value="${portal.chatUrl}"/>
<entry key="weiboUrl" value="${portal.weiboUrl}"/>
<entry key="servicePhone" value="${portal.customer.service.phone}"/>
<entry key="imagePrefix" value="${qiniu.image.url.prefix}"/>
<entry key="uploadUrl" value="https://up.qbox.me"/>
</map>
</property>
</bean>
说明:
一:value="${portal.customer.service.phone}"直接获取properties文件的变量
<entry key="imagePrefix" value="${qiniu.image.url.prefix}"/>
二、直接配置字符串
<bean id="freeMarkerConfigurer"
class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
<property name="templateLoaderPath" value="/WEB-INF/pages/"/>
<property name="defaultEncoding" value="UTF-8"/>
<property name="freemarkerSettings" ref="freemarkerConfiguration"/>
<property name="freemarkerVariables">
<map>
<entry key="shiro" value-ref="shiroTags"/>
<entry key="chatUrl" value="${portal.chatUrl}"/>
<entry key="weiboUrl" value="${portal.weiboUrl}"/>
<entry key="servicePhone" value="${portal.customer.service.phone}"/>
<entry key="imagePrefix" value="${qiniu.image.url.prefix}"/>
<entry key="uploadUrl" value="https://up.qbox.me"/>
</map>
</property>
</bean>
说明:
一:value="${portal.customer.service.phone}"直接获取properties文件的变量
<entry key="imagePrefix" value="${qiniu.image.url.prefix}"/>
二、直接配置字符串
<entry key="uploadUrl" value="https://up.qbox.me"/>
相关文章推荐
- Mysql:命令选项、配置选项、(全局、会话)系统变量、状态变量:(动态)系统变量
- Mysql:命令选项、配置选项、(全局、会话)系统变量、状态变量:SQL模式
- Windows、Linux系统安装JDK配置Java环境变量
- Windows、Linux系统安装JDK配置Java环境变量
- JAVA系统环境变量配置
- Mysql:命令选项、配置选项、(全局、会话)系统变量、状态变量:状态变量
- Mysql:命令选项、配置选项、(全局、会话)系统变量、状态变量:命令选项
- Win 8系统 Java开发环境搭建以及环境变量path的配置
- Linux系统下JDK安装,Java环境变量配置
- Ubuntu12.10 64位系统安装以及配置java、jdk环境变量
- linux 系统配置java环境变量
- 配置JAVA系统的环境变量
- 在linux系统中配置java环境变量的三种方法
- CentOS系统下配置java环境变量
- XP系统中Java环境变量配置
- win7 系统下配置 java 环境变量———细节决定成败,一个逗号都不能忽略!
- Mysql:命令选项、配置选项、(全局、会话)系统变量、状态变量:系统变量
- 在linux系统中配置java环境变量的三种方法
- Mysql:命令选项、配置选项、(全局、会话)系统变量、状态变量:(仅会话)系统变量
- Windows、Linux系统安装JDK配置Java环境变量