spring+freemarker 乱码解决办法

    这样应该可以了~

<!-- freemarker config -->
    <bean id="freemarkerConfig"
        class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
        <property name="templateLoaderPath" value="/WEB-INF/views/" />
        <property name="freemarkerSettings">
            <props>
                <prop key="localized_lookup">false</prop>
                <prop key="datetime_format">MM/dd/yyyy</prop>
                <prop key="whitespace_stripping">true</prop>
                <prop key="template_update_delay">0</prop>
                <prop key="output_encoding">UTF-8</prop>
                <prop key="default_encoding">UTF-8</prop>
                <prop key="url_escaping_charset">UTF-8</prop>
            </props>
        </property>
    </bean>

    <!-- View resolvers can also be configured with ResourceBundles or XML files. 
        If you need different view resolving based on Locale, you have to use the 
        resource bundle resolver. -->
    <bean id="viewResolver"
        class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
        <property name="contentType" value="text/html;charset=UTF-8"/>
        <property name="cache" value="true" />
        <property name="prefix" value="" />
        <property name="suffix" value=".ftl" />
    </bean>

 

posted @ 2013-12-30 18:51  Monn  阅读(413)  评论(0编辑  收藏  举报