SpringBoot-Learning
SpringBoot-Learning copied to clipboard
chapter 2-1
idea测试出中文乱码问题。 java.lang.AssertionError: Response content Expected: "[{"id":1,"name":"测试大师","age":20}]" but: was "[{"id":1,"name":"???è???¤§???","age":20}]" 搜了半天,file encoding都改成utf-8了,但是还是乱码。
@RequestMapping(value = "/users", produces = "application/json;charset=utf8")
类上的注解,改为这样就可以了。
通过实现 WebMvcConfigurer 中的configureMessageConverters 这种方式,经我实测无效。