import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@Retention(RetentionPolicy.RUNTIME)
@interface GetView {
String Method();
String Value();
}
public class Temp {
@GetView(Method = "aa", Value = "bb")
public void test() {
System.out.println("In test method.");
}
public static void main(String[] args) throws ClassNotFoundException, IllegalArgumentException, IllegalAccessException, InvocationTargetException, SecurityException, NoSuchMethodException {
Temp temp = new Temp();
Method method = temp.getClass().getMethod("test");
System.out.println(method.isAnnotationPresent(GetView.class));
method.invoke(temp);
GetView view = method.getAnnotation(GetView.class);
System.out.println(view.Method());
System.out.println(view.Value());
}
}

- 深圳市一键一家网络科技有限公司官方网址:http://www.songhu9.com.cn
- QQ:316675593,电话号码:19807655856
- 业务范围:公司网站建设、管理软件研发、软件网站二次开发、400电话、电商平台研发、公众号研发!
- 免责申明:本站内容均来源于网络,版权归原创所有,如有任何版权方面的问题,请与我们联系处理!