I am using spring-mvc with freemarker-2.3.27-incubating.jar
. And bean configuration for view-resolver like below...
<bean id="freemarkerConfig" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
<property name="templateLoaderPath" value="/"/>
<property name="freemarkerSettings">
<props>
<prop key="template_exception_handler">rethrow</prop>
<prop key="number_format">0.########</prop>
<prop key="date_format">dd/MM/yyyy</prop>
</props>
</property>
</bean>
<bean id="viewResolver" class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
<property name="suffix" value=".ftl"/>
<property name="exposeSpringMacroHelpers" value="true"/>
<property name="exposeRequestAttributes" value="true"/>
<property name="exposeSessionAttributes" value="true"/>
<property name="requestContextAttribute" value="rc"/>
</bean>
Where and how can I use <#ftl output_format="HTML">
or <#ftl output_format="HTML" auto_esc=true>
to enable HTML auto-scape
?
The #ftl
tags you just add at the beginning of the template files themselves. But I would recommend setting recognize_standard_file_extensions
to true
in the freemarkerSettings
properties, and then use .ftlh
file extension instead of .ftl
. Or, even better, you set incompatible_improvements
to 2.3.27
there instead, which enables recognize_standard_file_extensions
and some fixes. (Last not least, in case you want this for .ftl
for some reason, you can set output_format
to HTMLOutputFormat
in freemarkerSettings
properties too.)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.