一、添加@RequestMapping注解,配置produces的值
- @RequestMapping(value = "/add", produces = {"application/json;charset=UTF-8"})
这用方法只能修改添加了produces的@requestmapping
二、修改springmvc-xml
在springmvc-xml最前面加上下面的代码,就可以解决所有的
<!-- 转换编码为utf-8的bean, 需要放在最前面--> <bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter"> <property name="messageConverters"> <list> <bean class="org.springframework.http.converter.StringHttpMessageConverter"> <property name="supportedMediaTypes"> <list> <value>text/plain;charset=UTF-8</value> </list> </property> </bean> </list> </property> </bean>