解决@ResponseBody出现乱码以及返回List集合出现406问题

来源:互联网 发布:java map 修改value值 编辑:程序博客网 时间:2024/05/19 21:17

1.首先是乱码问题:

@RequestMapping(value = "/path",method = RequestMethod.GET,produces="text/plain;charset=UTF-8")
这个还是比较好的,当然啊如果是返回List集合的话,在你的springmvc配置文件中加上这个:

<!--<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">-->    <!--<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>-->
这个虽然是解决了返回集合,但是前端接收的值,有点怪,所以我还是比较喜欢返回字符串(可以把集合转换为字符串来着)

阅读全文
0 0