jsp tag file中使用c:when 标签无法正确判断的问题

来源:互联网 发布:广发华福软件 编辑:程序博客网 时间:2024/04/30 09:49

今天使用jsp tag file来引入内容,并在tag file中使用了c:when 标签:

<%@tag language="java" pageEncoding="UTF-8" isELIgnored="false"%><%@attribute name="obj" required="true"><c:choose><c:when test="${obj == 'text'}">if -text         </c:when>         <c:when test="${obj=='select'}">if -select         </c:when>    </c:choose>

然后很happy地在jsp中引入该tag文件:

<tag:XXX obj='text'/>

之后到浏览器一跑,结果text和select都显示出来了,查找半天不得结果,最后发现还要在tag file里边引入core的tag包,哪怕你在jsp中引用了,也必须到tag file中引用才行。将tagfile修改为:

<%@tag language="java" pageEncoding="UTF-8" isELIgnored="false"%><%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%><%@attribute name="obj" required="true"><c:choose><c:when test="${obj == 'text'}">if  -text         </c:when>         <c:when test="${obj=='select'}">if  -select         </c:when>    </c:choose>

再重新在浏览器中刷新,即可显示出text,不会出现select了。。。