Spring velocity 中文乱码 解决方案
2009-04-30 20:58
183 查看
主要有这么几步,在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。
蓝色字体为关键,其它根据你的实际情况配置:
<!-- ========================= 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 中文乱码 解决方案
- spring下使用velocity的中文乱码问题
- velocity中文乱码最终解决方案
- springmvc responseBody返回中文乱码解决方案
- Spring Boot 中文乱码解决方案
- Spring MVC POST中文乱码解决方案
- sitemesh2.x+velocity+springmvc乱码解决方案
- SpringBoot中,RestTemplate中文乱码解决方案
- velocity中文乱码最终解决方案
- Spring MVC 结合Velocity视图出现中文乱码的解决方案
- Spring MVC @ResponseBody 中文乱码 解决方案
- velocity中文乱码最终解决方案
- SpringMVC POST/GET 中文乱码 解决方案
- SpringMVC ResponseBody返回中文乱码解决方案
- velocity中文乱码最终解决方案
- spring4 Controller @ResponseBody中文乱码解决方案
- spring boot 学习笔记(06)——中文乱码解决方案
- Mysql之命令行中文乱码解决方案
- [zz]谈论MySQL与JSP中文乱码问题的解决方案
- Safari浏览器显示PHP文件中文出现乱码解决方案