解决html视图解析器,html乱码

项目编码,html页面编码浏览器解析编码都应该一致

html页面可以添加:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

   
   
   
   
  • 1
  • 2
  • 3
  1. html视图解析器:
    <bean id="viewResolver"
        class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
        <property name="exposeRequestAttributes" value="true" />
        <property name="exposeSessionAttributes" value="true" />
        <property name="viewClass">
            <value>org.springframework.web.servlet.view.freemarker.FreeMarkerView
            value>
        property>
        <property name="cache">
            <value>truevalue>
        property>
        <property name="suffix">
            <value>.htmlvalue>
        property>
        <property name="contentType">
            <value>text/html; charset=UTF-8value>
        property>
    bean>

    <bean id="freemarkerConfig"
        class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
        <property name="templateLoaderPath">
            <value>/WEB-INF/views/value>
        property>
        <property name="freemarkerSettings">
            <props>
                <prop key="locale">zh_CNprop>
                <prop key="defaultEncoding">UTF-8prop>
                
                
                
                
            props>
        property>
    bean>

你可能感兴趣的:(SpringMVC)