SpringBoot-Learning icon indicating copy to clipboard operation
SpringBoot-Learning copied to clipboard

chapter 2-1

Open Godxia opened this issue 4 years ago • 1 comments

idea测试出中文乱码问题。 java.lang.AssertionError: Response content Expected: "[{"id":1,"name":"测试大师","age":20}]" but: was "[{"id":1,"name":"???è???¤§???","age":20}]" 搜了半天,file encoding都改成utf-8了,但是还是乱码。

Godxia avatar Jul 29 '20 02:07 Godxia

@RequestMapping(value = "/users", produces = "application/json;charset=utf8")

类上的注解,改为这样就可以了。

通过实现 WebMvcConfigurer 中的configureMessageConverters 这种方式,经我实测无效。

ponyhu avatar Aug 06 '20 13:08 ponyhu