JSTL、EL表达式里面的逻辑判断

在jsp页面上使用c:if判断,判断条件中使用&&进行逻辑判断。 代码以下:jsp

<%
    	String userComcode = "44This is first String." ;
    	request.setAttribute("userComcode", userComcode);
    %>
    ${ userComcode  } <br>
    ${ userComcode != null }<br>
    ${ fn:substring(userComcode, 0, 2) == '44' }<br>
    <c:if test="${ fn:substring(userComcode, 0, 4) != '4403' }">
    	${ fn:substring(userComcode, 0, 4)}
    </c:if>
    <br>
    <c:if test="${userComcode != null && fn:substring(userComcode, 0, 2) == '44' && fn:substring(userComcode, 0, 4) != '4403'}">
    	显示
    </c:if>

在调试过程当中遇到一个问题,就是三个条件单独使用的时候都是true,可是合并起来就是不显示 查了不少资料发现写法都没有错误。 最后比对成功执行的发现 test,= ,“” 之间有空格, 把空格取消掉,就成功执行了。我也不明白为什么如此神奇。 反正就这么稀里糊涂解决了。调试

相关文章
相关标签/搜索