摘要:
有一些特殊的任务需要在系统启动前执行,例如配置文件加载、数据库初始化等操作。如果没有使用Spring Boot,这些问题可以在Listener 中解决。Spring Boot 对此提供了两种解决方案:CommandLineRunner 和ApplicationRunner 。CommandLineR 阅读全文
摘要:
public class MyInterceptor1 implements HandlerInterceptor { @Override public boolean preHandle(HttpServletRequest request, HttpServletResponse respons 阅读全文
摘要:
4.4 节向读者介绍了Spring Boot 中的全周异常处理。在处理异常时, 开发者可以根据实际情况返回不同的页面,但是这种异常处理方式一般用来处理应用级别的异常,有一些容器级别的错误就处理不了,例如Filter 中抛出异常,使用@ControllerAdvice 定义的全局异常处理机制就无法处理 阅读全文