Skip to content

Instantly share code, notes, and snippets.

@alexlamazing
Created May 5, 2017 03:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexlamazing/93e7d40e081606eee3735595aeb25f26 to your computer and use it in GitHub Desktop.
Save alexlamazing/93e7d40e081606eee3735595aeb25f26 to your computer and use it in GitHub Desktop.
<?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:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-3.0.xsd">
<bean id="freemarkerConfig"
class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
<property name="templateLoaderPaths">
<list>
<value>/WEB-INF/freemarker/</value>
<!--
<value>/</value>
<value>classpath:modules</value>
<value>classpath:org/springframework/web/servlet/view/freemarker
</value>
-->
</list>
</property>
<!-- 直接將Freemarker.propertyies寫在單獨的.properties注入進來 -->
<property name="freemarkerSettings">
<props>
<!--<prop key="template_update_delay">60000</prop> -->
<prop key="default_encoding">UTF-8</prop><!--範本的編碼格式-->
<prop key="locale">UTF-8</prop><!--當地語系化設置-->
<prop key="datetime_format">MM/dd/yyyy</prop>
<prop key="number_format">#</prop>
<prop key="whitespace_stripping">true</prop>
</props>
</property>
<!--全域變數部分 -->
<property name="freemarkerVariables">
<map>
<entry key="xml_escape" value-ref="fmXmlEscape" />
<entry key="html_escape" value-ref="fmHtmlEscape" />
</map>
</property>
<property name="defaultEncoding" value="utf-8" />
</bean>
<!-- ========================= Freemarker View Resolver ========================= -->
<bean id="viewResolverFreemarker" class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
<property name="cache" value="false"/>
<property name="prefix" value="" />
<property name="suffix" value=".ftl" />
<property name="allowSessionOverride" value="true" />
<!--如果你需要使用Spring 對 FreeMarker 巨集命令的支援, 將這個屬性設為true -->
<property name="exposeSpringMacroHelpers" value="true" />
<property name="order" value="1" />
<property name="contentType" value="text/html" />
</bean>
<bean id="fmXmlEscape" class="freemarker.template.utility.XmlEscape"/>
<bean id="fmHtmlEscape" class="freemarker.template.utility.HtmlEscape" />
<context:component-scan base-package="com.hket.itsdemo.spring.mvc.controller"/>
<!-- ========================= sysmsg ========================= -->
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
<property name="basename" value="messages"/>
</bean>
</beans>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment