访问注解与自定义注解
来源:互联网 发布:手机录音放大软件 编辑:程序博客网 时间:2024/05/17 00:51
访问注解:
t = Class.forName(className); //请求配置 Class<RequestMapping> annClass = org.springframework.web.bind.annotation.RequestMapping.class; //api 解释 Class<ApiExplain> annApiExplain = com.sinky.api.ApiExplain.class; //权限 Class<RequiresRoles> annRequiresRoles = org.apache.shiro.authz.annotation.RequiresRoles.class; //请求 Annotation annotationClass = t.getAnnotation(annClass); //api类注释 Annotation annotationClassDescription = t.getAnnotation(annApiExplain); classStr = getAnnValues(annotationClass); if (null == classStr) continue; System.out.println("类注解:" + classStr); Method[] methods = t.getMethods(); for (Method m : methods) { methodStr = getAnnValues(m.getAnnotation(annClass), annotationClass, m.getName(), className, m.getAnnotation(annApiExplain), annotationClassDescription, m.getAnnotation(annRequiresRoles) ); if (null == methodStr) continue; System.out.println("方法:" + m.getName() + " " + methodStr); } } catch (ClassNotFoundException e) { e.printStackTrace(); }自定义注解:
import java.lang.annotation.Documented;import java.lang.annotation.ElementType;import java.lang.annotation.Retention;import java.lang.annotation.RetentionPolicy;import java.lang.annotation.Target;import org.springframework.web.bind.annotation.Mapping;/** * * 用于提供api注释 * <功能详细描述> * * @author liubeihua * @version [版本号, 2016年1月13日] */@Target({ElementType.METHOD, ElementType.TYPE})@Retention(RetentionPolicy.RUNTIME)@Documented@Mappingpublic @interface ApiExplain{ /** * 描述 * @return */ String description() default ""; String other() default ""; String value() default "";}
0 0
- 访问注解与自定义注解
- 自定义注解与使用
- 注解初体验与自定义注解实战
- Java注解与自定义注解处理器
- Java注解(三) 自定义注解与提取注解
- Java注解(三) 自定义注解与提取注解
- 自定义注解与设计模式
- Java注解-自定义注解
- 【注解】02.自定义注解
- Java注解----自定义注解
- Java注解自定义注解
- 【Java】【注解】自定义注解
- Java 自定义注解实现网络访问重试
- 自定义注解
- 自定义注解
- 自定义注解
- 自定义注解
- 自定义注解
- js中将字符串转换成数字
- 微信创建自定义菜单和删除自定义菜单
- 使用ViewGrop和Fragment对Fragmen进行缓存
- 在Ubuntu下安装nodejs4.x,并实现开机自动启动forever进程守护nodejs应用后台运行
- 全局大喇叭,广播机制初篇。
- 访问注解与自定义注解
- lightoj 1017 - Brush (III)
- Linux(CentOS)环境下MySQL的安装、配置与使用
- 《MVC + EF实现增删改查》——操作EF实体详解与删除
- 什么是面向对象
- NOI国家集训队论文集
- UltraEdit软件破解说明
- 18、数据存储_01前言(这种东西最难写了)
- Hibernate 的工作原理 (面试)