参考:https://www.cnblogs.com/2013jiutian/p/7294053.html
@RequestMapping("/value1")
@Controller
public Class A {
@RequestMapping("/value2")
public String method1() {
return "xxx";
}
}
Annotation classAnnotation = A.class.getAnnotation(RequestMapping.class);
if (classAnnotation != null) {
Class clazz = classAnnotation.annotationType();
try {
Method path = clazz.getDeclaredMethod("path");
Method value = clazz.getDeclaredMethod("value");
String[] pathArr = (String[]) path.invoke(classAnnotation);
String[] valueArr = (String[]) value.inivoke(classAnnotation);
} catch (Exception e) {
e.printStackTrace();
}
}
Method method1 = A.class.getMethod("method1");
Annotation method1Annotation = method1.getAnnotation(RequestMapping.class);
...