方法一、在注解@RequestMapping 中添加 produces = {"application/json;charset=UTF-8"}
方法二、在配置文件中添加:
<mvc:annotation-driven> <!-- 解决返回String时乱码 --> <mvc:message-converters register-defaults="true"> <bean class="org.springframework.http.converter.StringHttpMessageConverter"> <property name="supportedMediaTypes"> <list> <value>text/plain;charset=UTF-8</value> <value>text/html;charset=UTF-8</value> </list> </property> </bean> </mvc:message-converters> </mvc:annotation-driven>
时间: 2024-10-26 15:07:38