转自:
下文讲述AbstractControllerUrlHandlerMapping类的简介说明,如下所示:
AbstractControllerUrlHandlerMapping的功能:
此类将实现Controller接口或注释了@Controller的bean作为Handler
并且可以通过设置excludedClasses和excludedPackages
将不包含的bean或不包含的包下的所有bean排除在外
determineUrlsForHandler()方法的功能
determineUrlsForHandler() 获取bean并完成beanName和beanClass的对应关系
@Override
protected String[] determineUrlsForHandler(String beanName) {
Class beanClass = getApplicationContext().getType(beanName);
//判断是不是支持的类型
if (isEligibleForMapping(beanName, beanClass)) {
//模板方法,在子类实现
return buildUrlsForHandler(beanName, beanClass);
}
else {
return null;
}
}
setIncludeAnnotatedControllers() 配置操作
public void setIncludeAnnotatedControllers(boolean includeAnnotatedControllers) {
this.predicate = (includeAnnotatedControllers ? new AnnotationControllerTypePredicate() : new ControllerTypePredicate());
}
public void setExcludedPackages(String... excludedPackages) {
this.excludedPackages = (excludedPackages != null) ? new HashSet(Arrays.asList(excludedPackages)) : new HashSet();
}
public void setExcludedClasses(Class... excludedClasses) {
this.excludedClasses = (excludedClasses != null) ? new HashSet>(Arrays.asList(excludedClasses)) : new HashSet>();
}
Original: https://blog.csdn.net/qq_25073223/article/details/127815810
Author: qq_25073223
Title: AbstractControllerUrlHandlerMapping类简介说明
原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/653045/
转载文章受原作者版权保护。转载请注明原作者出处!