具有多个运算符的JSTL条件 [英] JSTL Condition with multiple operators

查看:91
本文介绍了具有多个运算符的JSTL条件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在JSTL中编写一个具有多个运算符的条件.

I am trying to write a condition in JSTL that has multiple operators.

<c:if test="${!memberObj.provider && empty subscriptions or subscriptions eq false}"></c:if>

上述操作无法正确执行,因为需要包含空订阅或假订阅eq" .

The above doesn't execute correctly, because "empty subscriptions or subscriptions eq false" needs to be contained.

我希望能够做到:

${!memberObj.provider && (empty subscriptions or subscriptions eq false)}

但是,当我这样做时,jsp页面将变为空白.我猜这意味着出了点问题...

But the jsp page goes blank when I do that. Which I am guessing means something is off...

如何在JSTL中的单个条件下组合和",或"运算符?

How can I combine "and" and "or" operators in a single condition in JSTL?

提前谢谢!

推荐答案

这看起来很有效(尽管有点笨拙;几种样式混合在一起,不需要进行布尔比较).

This looks valid (albeit a bit clumsy; several styles are mixed and that boolean comparison is unnecessary).

浏览器检索无效的HTML时可以空白.我敢打赌,在代码中还有一些Java代码在响应已经提交时引发了异常.由于响应已经提交,因此服务器将无法完整显示错误页面(尽管它将记录异常).浏览器最终将收到带有不完整HTML的半生半熟的响应,该HTML无法被浏览器以任何明智的方式解释,因此它将变为空白.

A browser can go blank when it retrieved invalid HTML. I'd bet that there's some Java code further down in the code which threw an exception while the response is already committed. As the response is already committed, the server won't be able to show the error page in its full glory (although it would log the exception). The browser will end up with a halfbaked response with incomplete HTML which the browser can't interpret in any sensible way, hence it will go blank.

这篇关于具有多个运算符的JSTL条件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆