2019独角兽企业重金招聘Python工程师标准>>>

@Target(value=TYPE)
@Retention(value=RUNTIME)
@Documented
@Component
public @interface ControllerAdvice

Indicates the annotated class assists a "Controller". Serves as a specialization of @Component, allowing for implementation classes to be autodetected through classpath scanning. It is typically used to define @ExceptionHandler, @InitBinder, and @ModelAttribute methods that apply to all @RequestMapping methods. One of annotations(), basePackageClasses(), basePackages() or its alias value() may be specified to define specific subsets of Controllers to assist. When multiple selectors are applied, OR logic is applied - meaning selected Controllers should match at least one selector. The default behavior (i.e. if used without any selector), the @ControllerAdvice annotated class will assist all known Controllers. Note that those checks are done at runtime, so adding many attributes and using multiple strategies may have negative impacts (complexity, performance). Since: 3.2 Author: Rossen Stoyanchev, Brian Clozel, Sam Brannen 上面的意思是带有 @ControllerAdvice的类,作为 @Controller类 的组成部分,通常用来定义 @ExceptionHandler, @InitBinder, 和 @ModelAttribute 这样的方法,作用的返回由这个注解的 annotations(), basePackageClasses(), basePackages() 或者别名 value()筛选,如果同时设置了这几个值,因为多个条件之间的关系是 OR的关系,所以满足任何一个条件的 Controller 都会被作用。

tips:

本文由wp2Blog导入,原文链接:http://devonios.com/controller-advice-annotation.html

转载于:https://my.oschina.net/yangyan/blog/859247

SpringMVC @ControllerAdvice 注解的官方解释相关推荐

  1. SpringMVC重要注解(二)@ControllerAdvice

    @ControllerAdvice,是Spring3.2提供的新注解,从名字上可以看出大体意思是控制器增强.让我们先看看@ControllerAdvice的实现: package org.spring ...

  2. SpringMVC:注解@ControllerAdvice的工作原理

    点击上方蓝色"方志朋",选择"设为星标"回复"666"获取独家整理的学习资料! 来源:blog.csdn.net/andy_zhang200 ...

  3. exceptionhandler注解_SpringMVC 中 @ControllerAdvice 注解的三种使用场景!

    @ControllerAdvice ,很多初学者可能都没有听说过这个注解,实际上,这是一个非常有用的注解,顾名思义,这是一个增强的 Controller.使用这个 Controller ,可以实现三个 ...

  4. springmvc常用注解与类型转换

    springmvc常用注解与类型转换 一:前置 spring -servlet.xml 注入 <!-- 启用spring mvc 注解 --><context:annotation- ...

  5. SpringMVC全注解环境搭建

    源代码: 链接:https://pan.baidu.com/s/1Lxb-riH–YQNIy3c0i8pFA 提取码:y3aq 文档地址:https://shphuang_aliyun.gitee.i ...

  6. @ControllerAdvice注解(全局异常捕获)

    背景 @ControllerAdvice 注解 通常用于定义@ExceptionHandler, @InitBinder和@ModelAttribute 适用于所有@RequestMapping方法的 ...

  7. spring mvc异常统一处理(ControllerAdvice注解)

    spring mvc异常统一处理(ControllerAdvice注解) 参考文章: (1)spring mvc异常统一处理(ControllerAdvice注解) (2)https://www.cn ...

  8. Spring boot异常统一处理方法:@ControllerAdvice注解的使用、全局异常捕获、自定义异常捕获

    Spring boot异常统一处理方法:@ControllerAdvice注解的使用.全局异常捕获.自定义异常捕获 参考文章: (1)Spring boot异常统一处理方法:@ControllerAd ...

  9. SpringMVC-学习笔记03【SpringMVC常用注解】

    Java后端 学习路线 笔记汇总表[黑马程序员] SpringMVC-学习笔记01[SpringMVC概述及入门案例][day01] SpringMVC-学习笔记02[参数绑定及自定义类型转换] Sp ...

最新文章

  1. MongoDB 在评论中台的实践
  2. 解决python安装第三方库速度很慢的问题(opencv为例)
  3. ICDM 2020 TOP3方案
  4. [转]HTTP协议及其请求头分析
  5. 数据结构:将二叉搜索树转换成一个排序的双向链表
  6. 大数据之-Hadoop3.x_MapReduce_ReduceJoin案例Reducer_案例_Debug调试---大数据之hadoop3.x工作笔记0132
  7. SOTA集结,2020登顶关系抽取的3篇佳作
  8. 分享几个vue后台模板
  9. 有基础学python看什么书好_python入门学习看什么书好,有什么书籍推荐
  10. 卸载Microsoft Edge浏览器
  11. 走近CTPN:1. 解读README
  12. html背景图片怎么设置圆角,div+css实现圆角背景文字导航条
  13. 国内外RTI产品调查情况
  14. transform.forward和vector3.forward的使用区别
  15. 超纯水工业水处理工程方案解析
  16. 在 Github 制作在线简历 PDF
  17. 文件不小心删除了怎么恢复?实用的两个小妙招
  18. 编译原理陈火旺第三版第七章课后题答案
  19. 求职必备||程序员的优秀简历都是这样来的
  20. 一个免费、快速好用的汉语拼音离线翻译工具

热门文章

  1. 华为机试题2[编程题] 汽水瓶
  2. 超炫JS拖拽翻页效果(左右拖拽html源码)
  3. ROS 图像相关的命令与应用
  4. SLAM中直接法分类及对应的项目
  5. EUCM鱼眼相机模型详解
  6. 面试题之求二叉树的深度
  7. java junit 运行_运行Junit方法项目启动不了
  8. 软件测试 java_关于Java单元测试,你需要知道的一切
  9. vscode php插件_「PHP从入门到颈椎病康复」基础篇——HelloWorld
  10. android购物车栏,Android怎么实现二级列表购物车功能