1
<jsp:element name="input">
    <jsp:attribute name="type">radio</jsp:attribute>
    <jsp:attribute name="id">${status.index}${loop.index}</jsp:attribute>
    <jsp:attribute name="name">skillLevel[${status.index}].skillLevelId</jsp:attribute>
    <jsp:attribute name="value">${4 - loop.index}</jsp:attribute>
    <c:if test = "${(4 - loop.index) == skillLevel.getSkillLevelId()}">
        <jsp:attribute name="checked">checked</jsp:attribute>
    </c:if>
</jsp:element>

显示 c:if 标记不能在 jsp:element 标记内的错误。我只想根据测试条件为“input”元素添加“checked”属性。

4

1 回答 1

0

你试过这样吗?

<c:if test = "${(4 - loop.index) == skillLevel.getSkillLevelId()}">
<c:set var="isChecked" value="checked"/>
</c:if>

<jsp:element name="input">
    <jsp:attribute name="type">radio</jsp:attribute>
    <jsp:attribute name="id">${status.index}${loop.index}</jsp:attribute>
    <jsp:attribute name="name">skillLevel[${status.index}].skillLevelId</jsp:attribute>
    <jsp:attribute name="value">${4 - loop.index}</jsp:attribute>
    <jsp:attribute name="${isChecked}">${isChecked}</jsp:attribute>
</jsp:element>
于 2013-06-06T13:46:49.433 回答