<!-- 设置 ViewResolver --> <bean id="freemarkerConfiguration" class="org.springframework.ui.freemarker.FreeMarkerConfigurationFactoryBean"> <property name="templateLoaderPath" value="file://${ln.jtf.template.templatePath}" /> <property name="freemarkerSettings"> <props> <prop key="default_encoding">UTF-8</prop> <prop key="number_format">#</prop> <!-- 配置缓存时间 --> <prop key="template_update_delay">${lv.jtf.template.update.delay}</prop> <prop key="classic_compatible">true</prop> <prop key="url_escaping_charset">UTF-8</prop> <prop key="defaultEncoding">UTF-8</prop> <prop key="boolean_format">true,false</prop> <prop key="datetime_format">yyyy-MM-dd HH:mm:ss</prop> <prop key="date_format">yyyy-MM-dd</prop> <prop key="locale">zh_CN</prop> </props> </property> </bean>
一个default_encoding,一个defaultEncoding。
<!-- Spring MVC页面层 -->
<bean id="freemarkerViewResolver" class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver"> <property name="cache" value="true" /> <property name="prefix" value="/home/" /> <property name="suffix" value=".ftl" /> <property name="contentType" value="text/html; charset=UTF-8" /> <property name="attributes" ref="constants" /> <property name="exposeSpringMacroHelpers" value="true" /> </bean>