您的位置:首页 > 编程语言 > Java开发

SPRING MVC乱码解决

2016-04-12 09:59 246 查看
1. 方法上加注解
@RequestMapping(value="/query",produces = "text/html;charset=UTF-8")

2. spring配置文件中
<mvc:annotation-driven>
<mvc:message-converters register-defaults="true" >
<bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter" >
<property name="supportedMediaTypes">
<list>
<value>text/plain;charset=UTF-8</value>
</list>
</property>
</bean>
<bean class="org.springframework.http.converter.StringHttpMessageConverter" >
<property name="supportedMediaTypes">
<list>
<value>text/plain;charset=UTF-8</value>
</list>
</property>
</bean>
</mvc:message-converters>
</mvc:annotation-driven>

3. 数据连接
url=jdbc:mysql://192.168.1.112:3306/smvc?useUnicode=true&characterEncoding=UTF-8
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  spring mvc 乱码