我在我的jsp上使用以下表达式
<c:set var="flag" value="false" />
Run Code Online (Sandbox Code Playgroud)
我在每个循环中有一个条件,我可能想要将此变量更改为true.有没有办法做到这一点.我到处寻找但无法找到解决方案.
以下是您要查找的示例代码:
<c:choose>
<c:when test="${yourcondition}">
<c:set var="flag" value="true" />
</c:when>
<c:otherwise>
<c:set var="flag" value="false" />
</c:otherwise>
</c:choose>
Run Code Online (Sandbox Code Playgroud)
你也可以这样做
<c:set var="flag" value="${(yourcondition)? true : false}"/>
Run Code Online (Sandbox Code Playgroud)