springboot 快速整合springmvc

核心配置类

在启动类InTheWayApplication上添加@EnableWebMvc注解即可

去除直接返回中文乱码问题

1.增加配置

  1. @Configuration
  2. public class MyConfiguration extends WebMvcConfigurationSupport {
  3. @Bean
  4. public CharacterEncodingFilter characterEncodingFilter(){
  5. CharacterEncodingFilter filter = new CharacterEncodingFilter();
  6. filter.setEncoding("UTF-8");
  7. filter.setForceEncoding(true);
  8. return filter;
  9. }
  10. }

2 . 请求头添加

  1. @GetMapping(value = "/getSeckillPage",produces = "application/json;charset=utf-8")