简体   繁体   English

在JSTL中访问JSP标记的属性

[英]Accessing a JSP tag's attribute in JSTL

How do I access a JSP tag's attribute value within a JSTL tag? 如何在JSTL标记内访问JSP标记的属性值? In the code below, I would like to access the url attribute and test if it's empty. 在下面的代码中,我想访问url属性并测试它是否为空。 I am using the JSTL 1.0 specification. 我正在使用JSTL 1.0规范。

<%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %>
<%@ attribute name="url" required="false"%>

<c:if test="${!empty url}">
   ...
</c:if>

If you're creating tag files, then you're using at least JSP 2.0 - which means you should be using at least JSTL 1.1. 如果要创建标记文件,则至少要使用JSP 2.0-这意味着您应该至少使用JSTL 1.1。 At any rate, the attribute directive should create a page-scoped var with the same name as its name attribute (unless it's optional and not provided). 无论如何, attribute指令应该创建一个与它的name属性同名的页面范围的var(除非它是可选的并且未提供)。 So, can you provide any more detail on the errors and/or output you're observing? 因此,您能否提供有关所观察到的错误和/或输出的更多详细信息?

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

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