Get annotation class name in jsp page
When I add this code to the jsp page:
<c:set var="wizard" value="nope"/>
<c:forEach var="annotation" items="${command['class'].getAnnotations()}">
${annotation['class'].simpleName}<br/>
<c:if test="${annotation['class'].simpleName == 'Wizard'}">
<c:set var="wizard" value="yes"/>
</c:if>
</c:forEach>
I am getting something like Proxy96
for annotation class name instead of real name. What can I do with this code, get the real name of the annotations?
+3
source to share
1 answer
You should use ${annotation.annotationType().name}
annotation to get the name instead ${annotation.class.simpleName}
. The Annotation object is simply a proxy that represents this annotation instance of this class.
Example:
<c:forEach var="annotation" items="${yourObject.annotations}">
Annotation: ${annotation.annotationType().name}<br/>
</c:forEach>
+1
source to share