第一种:会影响数据解析
当使用这种方式传递参数时 localhost:8088/student/del?ids=1,2 会把 1,2 成一个字符串,影响springMVC解析,该段配置必须放在annotation-driven之前,不推荐使用
<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/html;charset=UTF-8</value>
</list>
</property>
</bean>
</list>
</property>
</bean>
第二种:在springMVC.xml中配置:暂时没有发现问题
<mvc:annotation-driven>
<mvc:message-converters register-defaults="true">
<bean class="org.springframework.http.converter.StringHttpMessageConverter">
<constructor-arg value="UTF-8" />
</bean>
</mvc:message-converters>
</mvc:annotation-driven>
第三种:在controller的类或者方法上添加这样的注解,比较繁琐
@RequestMapping(value = "请求路径", produces = "application/json;charset=utf-8")
第一次写,在网上总结的,做个笔记