springboot @RestController 返回中文乱码
1、在具体的方法上指定返回编码
@RequestMapping(value = "index", produces = "text/html;charset=utf-8")
2 、WebMvcConfigurer统一配置
@Bean public HttpMessageConverter<String> responseBodyConverter() { return new StringHttpMessageConverter(Charset.forName("UTF-8")); } @Override public void configureMessageConverters(List<HttpMessageConverter<?>> converters) { converters.add(responseBodyConverter()); }