zoukankan      html  css  js  c++  java
  • spring配置freemarker

    <?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>

  • 相关阅读:
    面向过程--面向对象
    shiro有哪些组件?
    Redis的特点什么是?
    Spring Boot 有哪些优点?
    什么是 JavaConfig?
    HashMap和Hashtable的区别
    深入理解SQL的四种连接-左外连接、右外连接、内连接、全连接
    Linux指令--tar,gzip
    JQuery 学习总结及实例
    $(this) 和 this 关键字在 jQuery 中有何不同?
  • 原文地址:https://www.cnblogs.com/lvgg/p/6655355.html
Copyright © 2011-2022 走看看