zoukankan      html  css  js  c++  java
  • @ContrllerAdvice全局异常

    @ControllerAdvice,是Spring3.2提供的新注解,它是一个Controller增强器,可对controller中被 @RequestMapping注解的方法加一些逻辑处理。最常用的就是异常处理,需要搭配@ExceptionHandler使用

       

    @ExceptionHandler 注解用来指明异常的处理类型,即如果指定为 NullpointerException,则数组越界异常就不会进到这个方法中来

       

       

       

    @ControllerAdvice使用方法

       

    首先在SpringBoot中导入thymeleaf的依赖

       

    <dependency>

    <groupId>org.springframework.boot</groupId>

    <artifactId>spring-boot-starter-thymeleaf</artifactId>

    </dependency>

       

    其次在SpringBoot项目的templates文件夹中创建一个thymeleaf的html

       

    导入上图红框的依赖就可以使用thymeleaf的语法了!

       

  • 相关阅读:
    052-90
    052-89
    052-88
    052-87
    052-86
    html5的manifest
    js中数字转金钱格式
    CSS复合样式
    资料
    异步
  • 原文地址:https://www.cnblogs.com/fernfei/p/12079060.html
Copyright © 2011-2022 走看看