spring下使用velocity的中文乱码问题
2007-05-29 18:18
603 查看
1 为了简单,所有文档都用utf-8编码。
2 在xxxx-servlet.xml中配置使用velocity的view的返回编码为utf-8
<bean id="velocityViewResolver" class="org.springframework.web.servlet.view.velocity.VelocityViewResolver"><property name="suffix"><value>.vm</value></property>
<property name="contentType"><value>text/html;charset=UTF-8</value></property>
</bean>
3 在xxx-servlet.xml中配置velocity引擎使用的编码
<bean id="velocityConfigurer" class="org.springframework.web.servlet.view.velocity.VelocityConfigurer"><property name="resourceLoaderPath">
<value>/pc/vm/</value>
</property>
<property name="velocityProperties">
<props>
<prop key="input.encoding">utf-8</prop>
<prop key="output.encoding">utf-8</prop>
</props>
</property>
</bean>
有人说可以配置一个velocity.properties将input.encoding的信息配置。没试过,似乎可行。
这样基本上保证无乱码了。
相关文章推荐
- Springboot使用FastJson后,接口返回中文乱码的问题解决。
- Spring mvc 实例--使用velocity视图,解决中文乱码问题
- Java学习笔记37:Spring 使用 @ResponseBody 返回中文乱码问题解决
- 关于spring中使用redis中文乱码问题(redistemplate)
- Java 使用 Velocity 发送邮件中文内容乱码问题的解决办法
- spring使用@Value注解读取.properties文件时出现中文乱码问题的解决
- Java使用Velocity模板发送HTML格式邮件并解决中文乱码问题
- 解决spring3.0.5使用RestTemplate发送post请求响应中文乱码问题
- spring使用@Value标签读取.properties文件的中文乱码问题的解决
- 解决Springboot使用FastJson 返回中文乱码的问题
- spring使用@Value标签读取.properties文件的中文乱码问题的解决
- spring boot新手教程之使用FastJson解析JSON数据以及解决返回中文乱码问题
- springboot使用velocity模板乱码问题
- spring使用@Value标签读取*.properties文件的中文乱码问题的解决
- 解决使用cmd或powershell进行数据库(MySQL,SQLite3...)查询时中文乱码的问题
- Spring @ResponseBody 返回中文乱码问题
- Maven+SpringMVC+Hibernate+ajax:用ajax传递json到前台中文出现问号乱码问题
- kettle —— 使用Kttle抽取数据时,出现中文乱码问题
- C# Asp.net 前台使用utf-8编码传递中文参数 后台接收乱码的问题
- Spring mvc 使用Gson 返回Json数据 中文乱码问题