码迷,mamicode.com
首页 > 编程语言 > 详细

spring配置freemarker

时间:2017-04-01 12:33:21      阅读:146      评论:0      收藏:0      [点我收藏+]

标签:res   charset   模版   bsp   返回   tty   format   att   处理   

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">

<!-- FreeMarker视图解析 如返回student。。在这里配置后缀名htm和视图解析器。。 -->
<bean id="viewResolver"
class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.freemarker.FreeMarkerView" />
<property name="suffix" value=".html" />
<property name="contentType" value="text/html;charset=UTF-8" />
<property name="exposeRequestAttributes" value="true" />
<!-- 不开启session -->
<property name="exposeSessionAttributes" value="false" />
<property name="requestContextAttribute" value="request"/>
<!-- 使用Spring提供的FreeMarker宏 -->
<property name="exposeSpringMacroHelpers" value="true" />
</bean>
<!-- freemarker的配置 -->
<bean id="freemarkerConfigurer"
class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
<property name="templateLoaderPath" value="/WEB-INF/inborn" />
<property name="defaultEncoding" value="UTF-8" />
<property name="freemarkerSettings">
<props>
<!-- 用来指定更新模版文件的间隔时间,相当于多长时间检测一下是否有必要重新加载模版文件, 0 表示每次都重新加载,否则为多少毫秒钟检测一下模版是否更改
2147483647 -->
<prop key="template_update_delay">0</prop>
<prop key="locale">zh_CN</prop>
<prop key="defaultEncoding">UTF-8</prop>
<prop key="url_escaping_charset">UTF-8</prop>
<prop key="datetime_format">yyyy-MM-dd HH:mm:ss</prop>
<prop key="date_format">yyyy-MM-dd</prop>
<prop key="number_format">#.##</prop>
<prop key="whitespace_stripping">true</prop>
<!--空值处理 -->
<prop key="classic_compatible">true</prop>
<prop key="boolean_format">true,false</prop>
</props>
</property>
<property name="freemarkerVariables">
<map>
<entry key="moneyShow" value-ref="moneyFre"/>
<entry key="moneyGroup" value-ref="moneyFormat"/>
<entry key="friendlyLength" value-ref="lengthFre"/>
<entry key="timeFormat" value-ref="timeFre"/>
<entry key="title" value="胤宝"/>
<entry key="monyType" value="¥"/>
</map>
</property>
</bean>

 

<!-- 自定义金额标签 -->
<!-- 自定义金额标签 -->
<bean id="moneyFre" class="com.inborn.inshop.freemarker.MoneyFre"></bean>
<bean id="moneyFormat" class="com.inborn.inshop.freemarker.MoneyFormat"></bean>
<bean id="lengthFre" class="com.inborn.inshop.freemarker.LengthFre"></bean>
<bean id="timeFre" class="com.inborn.inshop.freemarker.TimeFre"></bean>

</beans>

spring配置freemarker

标签:res   charset   模版   bsp   返回   tty   format   att   处理   

原文地址:http://www.cnblogs.com/lvgg/p/6655355.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!