Get value of a parameter of an annotation in Java

To get value of the @Path parameter:

String path = Hello.class.getAnnotation(Path.class).value();

Similarly, Once you have hold of Method getHtml

Method m = Hello.class.getMethod("getHtml", ..);
String mime = m.getAnnotation(Produces.class).value;

Leave a Comment