我正在使用spring mvc freemarker-2.3.27-incubating.jar . 和视图解析器的bean配置,如下所示。。。
freemarker-2.3.27-incubating.jar
<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>
在哪里以及如何使用 <#ftl output_format="HTML"> 或 <#ftl output_format="HTML" auto_esc=true> 要启用 HTML auto-scape ?
<#ftl output_format="HTML">
<#ftl output_format="HTML" auto_esc=true>
HTML auto-scape
这个 #ftl 仅在模板文件开头添加的标记本身。但我建议设置 recognize_standard_file_extensions 到 true 在 freemarkerSettings 属性,然后使用 .ftlh 文件扩展名,而不是 .ftl . 或者,更好的是,你 incompatible_improvements 到 2.3.27 相反,这使 识别\u standard\u file\u扩展名 以及一些修复。(最后也是最重要的一点,如果你想要这个 .ftl公司 出于某种原因,您可以设置 output_format 到 HTMLOutputFormat 在里面 Freemarker设置 属性。)
#ftl
recognize_standard_file_extensions
true
freemarkerSettings
.ftlh
.ftl
incompatible_improvements
2.3.27
识别\u standard\u file\u扩展名
.ftl公司
output_format
HTMLOutputFormat
Freemarker设置