简体   繁体   English

JSTL如果标记始终执行为true

[英]JSTL if tag always execute as true

I am working with a JSTL and trying to implement a if tag 我正在使用JSTL,并尝试实现if标签

below is my code for file login.tag 以下是我的文件login.tag代码

<c:if test="${not empty param.error}">
        //do something
</c:if>

My understanding is when I access this page 我的理解是当我访问此页面时

with path/index.jsp   //the if tag is not executed 
with path/index.jsp?error=wrongpassword   //the if tag is executed

But what I am getting now is the if tag is always execute true , Please advice 但是我现在得到的是if标记始终执行true ,请指教

If you want to use c:if tag you should use JSP taglib directive for JSTL core tag library. 如果要使用c:if标记,则应对JSTL核心标记库使用JSP taglib指令。 Use below code at the top of the JSP 在JSP顶部使用以下代码

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

You also need libraries for JSTL as dependencies to your project. 您还需要JSTL库作为项目的依赖项。 See this answer to find maven dependencies. 查看答案以查找Maven依赖项。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM