首页 > 编程学习 > 如何使用el表达式判断多个值是否相等?

第一种:使用等号==判断

<c:if test="${v==1 && u==2}"></c:if>

第二种:使用eq判断

<c:if test="${v eq 1 and u eq 2}"></c:if>

对数值判断相等:可以用==也可以用eq

对字符串判断相等:用eq

多个值用&& 或者and 连接

对EL表达式中取到的值进行判断后显示:

<c:if test="${list.status eq 1}">正确<c:if>
<c:if test="${list.status eq 2}">错误<c:if>
然后记得在页面头部导入C标签
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

 


本文链接:https://www.ngui.cc/el/2927272.html
Copyright © 2010-2022 ngui.cc 版权所有 |关于我们| 联系方式| 豫B2-20100000