如何使用 c:if 标签测试 jsp 中的两个属性?
How can I test two attributes in jsp using c:if tag?
我想使用 jstl 标签 c:if 检查从服务器发送的两个属性在 jsp 中是否为空。例如,我可以用来检查错误是否为空:<c:if test="${not empty error}"></c:if>
像这样,我想检查两个对象错误并立即注销,如果其中一个为空,则生成 div。我该怎么做?
使用 AND 运算符 && 或 OR 运算符 ||
<c:if test="${not empty first && not empty second}"></c:if>
<c:if test="${not empty first || not empty second}"></c:if>
如果您希望它们为空
<c:if test="${empty first && empty second}"></c:if>
<c:if test="${empty first || empty second}"></c:if>
我想使用 jstl 标签 c:if 检查从服务器发送的两个属性在 jsp 中是否为空。例如,我可以用来检查错误是否为空:<c:if test="${not empty error}"></c:if>
像这样,我想检查两个对象错误并立即注销,如果其中一个为空,则生成 div。我该怎么做?
使用 AND 运算符 && 或 OR 运算符 ||
<c:if test="${not empty first && not empty second}"></c:if>
<c:if test="${not empty first || not empty second}"></c:if>
如果您希望它们为空
<c:if test="${empty first && empty second}"></c:if>
<c:if test="${empty first || empty second}"></c:if>