JSP中是否有任何类似于isset的函数? [英] Is there any isset-like function in JSP?
本文介绍了JSP中是否有任何类似于isset的函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道我们是否可以使用其内置函数检查JSP中的所有undefined
和null
变量?
I was wondering if we could check for all undefined
and null
variables in JSP using its built-in functions?
我知道我可以构建一个函数来做到这一点,但是我需要一个懒惰的解决方案.
I know I can build a function to do that, but I need a lazy solution.
推荐答案
<c:if test="${name == null}">variable name is undefined</c:if>
对于测试,您可以使用以下命令定义和取消定义变量:
For testing you can define and undefine a variable using:
<c:set var="name" value="Petra"/>
<c:set var="name" value="${null}"/>
要声明您正在使用核心JSTL标签,请将其添加到页面顶部:
To state you are using the core JSTL tags add this to the top of the page:
<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
这篇关于JSP中是否有任何类似于isset的函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文