如何在JSTL if语句中执行按位逻辑? [英] How do I perform bitwise logic within JSTL if statements?
本文介绍了如何在JSTL if语句中执行按位逻辑?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要在JSP中执行按位测试,但是我一生都无法弄清楚如何使用EL进行测试.
I have a need to perform a bitwise test within a JSP but can't for the life of me figure out how to do it with EL.
我想做类似的事情:
<c:if test="${(test & testFor) == testFor}">
<h3>Test Passed</h3>
</c:if>
我当然可以使用普通的JSP语法做到这一点:
Of course I can do it with ordinary JSP syntax:
<% if ((test & testFor) == testFor) { %>
<h3>Test Passed</h3>
<% } %>
推荐答案
I think bitwise operators are not implemented in JSTL (see here)
您可以实现名为bitwiseAnd(int, int)
的JSTL函数,并以Java代码执行按位测试
You can implement a JSTL function, called bitwiseAnd(int, int)
and perform the bitwise test in Java code
这篇关于如何在JSTL if语句中执行按位逻辑?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文