2つの条件を使用して2つの変数を設定しようとしていますが、動作しません。 私のコードスニペットは、以下の通りである:JSTLで条件が働いていない場合
<c:forEach items="${user.roles}" var="role">
<span>Value : ${role.id }</span> **<!-- Print the value perfectly-->**
<c:if test="${role.id == 3}">
<c:set var="admin" value="${role.id}"></c:set>
<span>Value : ${val }</span>
</c:if>
<c:if test="${role.id == 2}"> **<!-- But not work condition here -->**
<c:set var="supporter" value="${role.id}"></c:set>
<span>Value : ${val }</span>
</c:if>
</c:forEach>
<input type="checkbox" name="roles" value="3" ${admin ==3 ? 'checked' : ''}> Supporter
<input type="checkbox" name="roles" value="2" ${supporter ==2 ? 'checked' : ''}> Admin
付加されたタグのLib:
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
あなたが' '$'内部に使用してはならないためだと思います"$ {role.id ==}"を '$ {role.id ==}'と置き換えてください –