獲取方法上的注解,獲取類上面的注解
if(f.isAnnotationPresent(ApiModelProperty.class)){
//獲取類所有的方法
Method[] methods = Test01Controller.class.getMethods(); for (int i=0;i<methods.length;i++){
//獲取單個指定注解 Service annotation = methods[i].getAnnotation(Service.class); System.out.println(annotation); } //獲取所有注解 Annotation[] annotations = Test01Controller.class.getAnnotations(); for (int i=0;i<annotations.length;i++){ System.out.println(annotations[i]); }