首页 > 编程语言 > 详细

Spring velocity 中文乱码 解决方案

时间:2015-03-03 11:28:21      阅读:262      评论:0      收藏:0      [点我收藏+]

主要有这么几步,在spring web 的  [sevlet-name]-servlet.xml文件中,修改为:

黑体字体为关键,其它根据你的实际情况配置:

 

  <!-- ========================= VIEW DEFINITIONS ========================= -->
     <bean id="velocityViewResolver" class="org.springframework.web.servlet.view.velocity.VelocityViewResolver">
        <property name="suffix" value=".vm"></property>
        <property name="contentType"><value>text/html;charset=UTF-8</value></property> 
    </bean>
    
    <bean id="velocityConfigurer" class="org.springframework.web.servlet.view.velocity.VelocityConfigurer">
        <property name="resourceLoaderPath">
            <value>${pgallery.template}</value>
        </property>
        <property name="velocityProperties">
            <props>
                <prop key="input.encoding">utf-8</prop>
                <prop key="output.encoding">utf-8</prop>
            </props>
        </property> 

    </bean>

 

注:

首先要保证开发环境的文件编码统一,将jsp/html的字符编码都声明为utf-8。

Spring velocity 中文乱码 解决方案

原文:http://www.cnblogs.com/netcorner/p/4310353.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!