现象:
Myeclipse设置解析freemarker
方案:
1:新增ftl解析
2:设置
3:设置字符保存
4:设置完成
5:maven添加freemarker的jar包
6:springmvc配置文件设置freemmarker解析器代替视图解析器
7:spring配置文件中配置freemarker解析细节
8:新建立html文件将后缀改为ftl
freemarker视图解析器代码:
<!-- freemarker解析器 -->
<bean class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
<property name="contentType" value="text/html;charset=utf-8" />
<property name="suffix" value=".ftl"/>
</bean>
freemarker视图处理细节设置
<!-- freeMarker视图处理 -->
<bean id="freeMarkerConfigurer" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
<property name="templateLoaderPaths">
<array>
<value>classpath:/</value>
<value>WEB-INF/template</value>
</array>
</property>
<property name="freemarkerSettings">
<props>
<prop key="default_encoding">UTF-8</prop>
<prop key="url_escaping_charset">UTF-8</prop>
<prop key="output_format">HTMLOutputFormat</prop>
<prop key="template_update_delay">0</prop>
<prop key="tag_syntax">auto_detect</prop>
<prop key="classic_compatible">true</prop>
<prop key="number_format">0.######</prop>
<prop key="boolean_format">true,false</prop>
<prop key="datetime_format">yyyy-MM-dd</prop>
<prop key="date_format">yyyy-MM-dd</prop>
<prop key="time_format">HH:mm:ss</prop>
<prop key="object_wrapper">freemarker.ext.beans.BeansWrapper</prop>
</props>
</property>
<property name="freemarkerVariables">
<map>
<entry key="base" value="#{servletContext.contextPath}" />
</map>
</property>
</bean>
maven引入freemarkerjar包
<!-- maven引入freeMarker视图解析器jar包 -->
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>2.3.26-incubating</version>
</dependency>