类 ControllerAdviceBean
- java.lang.Object
- org.springframework.web.method.ControllerAdviceBean
- 所有已实现的接口:
Ordered
public class ControllerAdviceBean extends Object implements Ordered
Encapsulates information about an @ControllerAdvice Spring-managed bean without necessarily requiring it to be instantiated.The
findAnnotatedBeans(ApplicationContext)
method can be used to discover such beans. However, aControllerAdviceBean
may be created from any object, including ones without an@ControllerAdvice
.- 从以下版本开始:
- 3.2
- 作者:
- Rossen Stoyanchev, Brian Clozel, Juergen Hoeller
字段概要
从接口继承的字段 org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
构造器概要
构造器 构造器 说明 ControllerAdviceBean(Object bean)
Create aControllerAdviceBean
using the given bean instance.ControllerAdviceBean(String beanName, BeanFactory beanFactory)
Create aControllerAdviceBean
using the given bean name.
方法概要
所有方法 静态方法 实例方法 具体方法 修饰符和类型 方法 说明 boolean
equals(Object other)
static List<ControllerAdviceBean>
findAnnotatedBeans(ApplicationContext applicationContext)
Find the names of beans annotated with @ControllerAdvice in the given ApplicationContext and wrap them asControllerAdviceBean
instances.Class<?>
getBeanType()
Return the type of the contained bean.int
getOrder()
Returns the order value extracted from theControllerAdvice
annotation, orOrdered.LOWEST_PRECEDENCE
otherwise.int
hashCode()
boolean
isApplicableToBeanType(Class<?> beanType)
Check whether the given bean type should be assisted by this@ControllerAdvice
instance.Object
resolveBean()
Return a bean instance if necessary resolving the bean name through the BeanFactory.String
toString()
构造器详细资料
ControllerAdviceBean
public ControllerAdviceBean(Object bean)
Create aControllerAdviceBean
using the given bean instance.- 参数:
bean
- the bean instance
ControllerAdviceBean
public ControllerAdviceBean(String beanName, BeanFactory beanFactory)
Create aControllerAdviceBean
using the given bean name.- 参数:
beanName
- the name of the beanbeanFactory
- a BeanFactory that can be used later to resolve the bean
方法详细资料
getOrder
public int getOrder()
Returns the order value extracted from theControllerAdvice
annotation, orOrdered.LOWEST_PRECEDENCE
otherwise.- 指定者:
getOrder
在接口中Ordered
- 返回:
- the order value
- 另请参阅:
Ordered.HIGHEST_PRECEDENCE
,Ordered.LOWEST_PRECEDENCE
getBeanType
public Class<?> getBeanType()
Return the type of the contained bean.If the bean type is a CGLIB-generated class, the original user-defined class is returned.
resolveBean
public Object resolveBean()
Return a bean instance if necessary resolving the bean name through the BeanFactory.
isApplicableToBeanType
public boolean isApplicableToBeanType(Class<?> beanType)
Check whether the given bean type should be assisted by this@ControllerAdvice
instance.- 参数:
beanType
- the type of the bean to check- 从以下版本开始:
- 4.0
- 另请参阅:
ControllerAdvice
findAnnotatedBeans
public static List<ControllerAdviceBean> findAnnotatedBeans(ApplicationContext applicationContext)
Find the names of beans annotated with @ControllerAdvice in the given ApplicationContext and wrap them asControllerAdviceBean
instances.