zoukankan      html  css  js  c++  java
  • Spring Boot2.2.X中Tomcat配置 错误定制

    1: Tomcat定制

    EmbeddedServletContainerCustomizer 已久废弃 按照下面的方式来处理 通过的类的配置

    @Component
    public class TomcatConfig implements WebServerFactoryCustomizer<ConfigurableServletWebServerFactory> {
    
        @Override
        public void customize(ConfigurableServletWebServerFactory server) {
            server.setDisplayName("hello kugou");
            server.setPort(8082);
        }
    }

    2: 错误定制

    @Component
    public class ErrorConfig implements ErrorPageRegistrar {
     
        @Override
        public void registerErrorPages(ErrorPageRegistry registry) {
            ErrorPage error400Page = new ErrorPage(HttpStatus.BAD_REQUEST, "/error400Page");
            ErrorPage error401Page = new ErrorPage(HttpStatus.UNAUTHORIZED, "/error401Page");
            ErrorPage error404Page = new ErrorPage(HttpStatus.NOT_FOUND, "/error404Page");
            ErrorPage error500Page = new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/error500Page");
            registry.addErrorPages(error400Page,error401Page,error404Page,error500Page);
        }
    }

     

  • 相关阅读:
    spring_three
    报错:java.sql.SQLException: The server
    Spring_two
    Spring_One
    Mybatis中的collection和association一关系
    Mybatis_three
    文件操作1
    面向对象编程三大特征7
    面向对象编程三大特征6
    面向对象编程三大特征5
  • 原文地址:https://www.cnblogs.com/dgwblog/p/11984442.html
Copyright © 2011-2022 走看看