JSTL Condition with multiple operators

自闭症网瘾萝莉.ら 提交于 2019-12-10 16:14:55

问题


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>

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

I would expect to be able to do:

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

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

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

Thanks in advance!


回答1:


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

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.



来源:https://stackoverflow.com/questions/9103082/jstl-condition-with-multiple-operators

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!