<c:if test= > is always true

依然范特西╮ 提交于 2020-01-13 08:42:09

问题


I am stuck with the following code. On a JSP page, I want to write different things depending on the terminal the browser is accepted on. the terminal value is set properly in the controller but when executing the following code, all the 3 c:if conditions are considered valid and the three sentences are displayed

<c:if test="${terminal=='android'}">
    <p>you are on android</p>
</c:if>
<c:if test="${terminal=='iphone'}">
    <p>you are on iphone </p>
</c:if>
<c:if test="${terminal=='other'}">
    <p>you are on an other terminal </p>
</c:if>

To check whether the condition was ok, I added the following code which gives correctly true, false, false when accessing from an Android..

<p> ${terminal=='android'}</p>
<p>${terminal=='iphone'}</p>
<p>${terminal=='other'}</p>

Thanks in advance


回答1:


I just forgot to have the right library inclusion

Added

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

at the beggining of the file just works

Found the answer while browsing the comments of

https://stackoverflow.com/questions/10800010/jstl-cif-test-cif?rq=1



来源:https://stackoverflow.com/questions/20145622/cif-test-is-always-true

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