gpt4 book ai didi

java - jsp : set an attribute of an element based on condition

转载 作者:行者123 更新时间:2023-12-01 04:38:43 27 4
gpt4 key购买 nike

<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”属性。

最佳答案

你试过这样吗?

<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>

关于java - jsp : set an attribute of an element based on condition,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16963258/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com