jsp:根据条件设置元素的属性

vcudknz3  于 2021-06-30  发布在  Java
关注(0)|答案(1)|浏览(427)
  1. <jsp:element name="input">
  2. <jsp:attribute name="type">radio</jsp:attribute>
  3. <jsp:attribute name="id">${status.index}${loop.index}</jsp:attribute>
  4. <jsp:attribute name="name">skillLevel[${status.index}].skillLevelId</jsp:attribute>
  5. <jsp:attribute name="value">${4 - loop.index}</jsp:attribute>
  6. <c:if test = "${(4 - loop.index) == skillLevel.getSkillLevelId()}">
  7. <jsp:attribute name="checked">checked</jsp:attribute>
  8. </c:if>
  9. </jsp:element>

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

0yycz8jy

0yycz8jy1#

你试过这样吗?

  1. <c:if test = "${(4 - loop.index) == skillLevel.getSkillLevelId()}">
  2. <c:set var="isChecked" value="checked"/>
  3. </c:if>
  4. <jsp:element name="input">
  5. <jsp:attribute name="type">radio</jsp:attribute>
  6. <jsp:attribute name="id">${status.index}${loop.index}</jsp:attribute>
  7. <jsp:attribute name="name">skillLevel[${status.index}].skillLevelId</jsp:attribute>
  8. <jsp:attribute name="value">${4 - loop.index}</jsp:attribute>
  9. <jsp:attribute name="${isChecked}">${isChecked}</jsp:attribute>
  10. </jsp:element>

相关问题