楼主最近遇到一个要在js中写多条件的条件判断语句其中有个条件是类似于这种0<${aphot.count}<=5,楼主一开始是这么写的但是只进入第一个和最后一个
<c:forEach items="${listAp}" var="aphot">
alert("ap信息==>"+${aphot.id}+":"+${aphot.count});
<c:if test="${aphot.count == 0}">
alert("等于0");
</c:if>
<c:if test="${aphot.count>0} && ${aphot.count<=5}">
alert("0-5 :"+${aphot.xValue}+","+${aphot.yValue});
</c:if>
<c:if test="${aphot.count>5} && ${aphot.count<=10}">
alert("5-10:"+${aphot.xValue}+","+${aphot.yValue});
</c:if>
<c:if test="${aphot.count >10}">
alert("10以上:"+${aphot.xValue}+","+${aphot.yValue});
</c:if>
</c:forEach>
最后改成这样子每个条件都可以进去,后来发现像这种语句只用写一个“${}”符号,然后再一个里面做判断就行。
<c:forEach items="${listAp}" var="aphot">
alert("ap信息==>"+${aphot.id}+":"+${aphot.count});
<c:if test="${aphot.count == 0}">
alert("等于0");
</c:if>
<c:if test="${aphot.count>0 && aphot.count<=5}">
alert("0-5 :"+${aphot.xValue}+","+${aphot.yValue});
</c:if>
<c:if test="${aphot.count>5 && aphot.count<=10}">
alert("5-10:"+${aphot.xValue}+","+${aphot.yValue});
</c:if>
<c:if test="${aphot.count >10}">
alert("10以上:"+${aphot.xValue}+","+${aphot.yValue});
</c:if>
</c:forEach>