Spring中FrameMaker中文乱码
1. 模板文件
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/
html4/loose.dtd">
<html>
<head>
<metahttp-equiv="Content-Type"content="text/html;charset=UTF-8">
<title>PBWDP登录</title>
</head>
<body>
</body>
</html>2. 视图解析
<!-- Configure FreeMarker support -->
<beanid="freemarkerConfig"
class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
<propertyname="templateLoaderPath"value="/WEB-INF/ftl/"/>
<propertyname="freemarkerSettings">
<props>
<propkey="template_update_delay">1</prop>
<propkey="defaultEncoding">UTF-8</prop><!--中文乱码:也可改成GB2312-->
</props>
</property>
</bean>
<beanid="viewResolver"
class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
<propertyname="cache"value="true"/>
<propertyname="prefix"value=""/>
<propertyname="suffix"value=".ftl"/>
<propertyname="contentType"value="text/html;charset=UTF-8"/>
</bean>3. web.xml
<filter>
<filter-name>EncodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>Encoding</filter-name>
<url-pattern>/*</EncodingFilter>
</filter-mapping>