配置文件

大量的Servlet专属的server.* properties被移到了server.servlet下

拦截器

public class MyWebMvcConfigurerAdapter implements WebMvcConfigurer

静态资源被拦截

spring boot 2.0则对静态资源也进行了拦截

全局异常特殊处理

设置不同的状态码,转发到不同的页面上

@Configuration
public class ContainerConfig implements ErrorPageRegistrar {

    @Override
    public void registerErrorPages(ErrorPageRegistry registry) {
        ErrorPage[] errorPages = new ErrorPage[2];
        errorPages[0] = new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/error/500");
        errorPages[1] = new ErrorPage(HttpStatus.NOT_FOUND, "/error/404");
        registry.addErrorPages(errorPages);
    }
}

相关文章:

  • 2021-12-25
  • 2021-07-15
  • 2021-06-28
  • 2021-05-26
  • 2022-12-23
  • 2021-08-06
  • 2022-12-23
  • 2021-08-18
猜你喜欢
  • 2022-12-23
  • 2021-07-23
  • 2021-06-18
  • 2022-12-23
  • 2021-10-27
  • 2022-12-23
  • 2021-08-14
相关资源
相似解决方案