0

一直试图在网上寻找答案,但找不到。我有一个调用标签文件的jsp页面(如下),在这个标签文件中,我需要有条件地调用另一个标签文件。但是,无论我通过$loadScript传递什么值,内容都是包含的。

在我的 jsp 页面中,我传入了loadScript的值:(已更新)

<jsp:attribute name="loadScript">false</jsp:attribute>

这是我的标签文件中的内容:

<%@tag description="put the tag description here" pageEncoding="UTF-8"%>
<%@ attribute name="loadScript"%>
<%@ taglib tagdir="/WEB-INF/tags" prefix="main" %>

<html>
<head>
<c:if test="${loadScript == 'true'}">
    <main:script></main:script>  
</c:if>

</head>
</html>

有条件地调用/包含标记文件的正确方法是什么?

更新:是的,我可以使用此测试确认值已成功传输:

<c:if test="${'loadScript'}">
    <script type="text/javascript">
        alert(${loadScript});
    </script>
</c:if>

看起来<main:script></main:script>标签无论如何都会生成?

4

0 回答 0