Read annotation property

If I defined this class:

@MainForm(grupo = 3, icone = "user")
public class Usuario {
    ...
}

and go to the view of this list (including the class above):

public List<Class<?>> lista_classes_projeto() {
    ...
}

Is there a way to read the value for iconein this jsp code:

        <c:forEach var="option" items="${lista}">
            <li>
                <c:url value="/${option.simpleName}/listagem" var="url"/>
                <a class="link" href="${url}">
                    <i class="icon-"></i>
                    <span>${option.simpleName}</span>
                </a>
            </li>
        </c:forEach>
+4
source share
1 answer

I have not tested, but you could try this line: (in each for each)

((MainForm) option.getAnnotation(MainForm.class)).icone();

Note that null handling was ignored. I assume everyone option (class)has annotation@MainForm

0
source

All Articles