检查视图中的注释名称

时间:2014-08-20 23:19:55

标签: jsp annotations jstl el

在下面的代码中,目标是,对象传递给视图(命令),其字段(${fields})和每个字段(${annotations})的注释,生成用于插入特定类型(类)的新对象的表单。

我的问题是如何从每个注释中访问属性simpleName的值。在java代码中,我会使用:annotation.getAnnotationType().getSimpleName(),但是当我在jsp(${item2['annotationType'].simpleName)上尝试这个时,我收到一个错误:javax.el.PropertyNotFoundException: Property 'annotationType' not found on type com.sun.proxy.$Proxy96

任何人都可以告诉我如何做到这一点:

    <custom:MainForm action="${cadastra}" classe="${command['class'].simpleName}">
        <c:forEach var="item" items="${fields}" varStatus="status">
            <custom:FieldBox ordem="${status.index}">
                <div class="col-md-7">
                    <custom:Label/>
                </div>
                <div class="col-md-7">
                    <c:forEach var="item2" items="${annotations}">
                        <c:choose>
                            <c:when test="${item2['annotationType'].simpleName == 'Input'}">
                                <custom:Input/>
                            </c:when>
                            <c:when test="${item2['annotationType'].simpleName == 'Select'}">
                                <c:url value="/.../listagem.json" var="url"/>
                                <custom:Select lista="${url}"/>
                            </c:when>
                            <c:when test="${item2['annotationType'].simpleName == 'EmbedSelect'}">
                                <c:url value="/.../listagem.json" var="url"/>
                                <c:url value="/.../cadastra" var="cad"/>
                                <c:url value="/.../altera" var="alt"/>
                                <c:url value="/.../remove" var="del"/>
                                <custom:EmbedSelect lista="${url}" cadastra="" altera="" remove=""/>
                            </c:when>
                            <c:when test="${item2['annotationType'].simpleName == 'Textarea'}">
                                <custom:Textarea/>
                            </c:when>
                            <c:when test="${item2['annotationType'].simpleName == 'Checkbox'}">
                                <custom:Checkbox/>
                            </c:when>
                            <c:when test="${item2['annotationType'].simpleName == 'Radiobutton'}">
                                <custom:Radiobutton/>
                            </c:when>
                        </c:choose>
                    </c:forEach>
                </div>
            </custom:FieldBox>
        </c:forEach>
        <div class="row field-box">
            <button type="submit" class="btn btn-lg btn-primary">cadastrar</button>
        </div>
    </custom:MainForm>

0 个答案:

没有答案