通过 tiles/jsp:include 持久化的 JSTL 属性

JSTL attributes persisting through tiles/jsp:include

我目前正在为 Web 应用程序使用 JSTL 和 Tiles(虽然我很确定这个问题不是 tiles 问题)。

我想在模板级别包含一个 "setVars" 文件,该文件是一个包含大量 JSTL 变量的简单文件

例如

testPageVars.jsp

<c:set var="currentPage" value="testPage" scope="request" />
<c:set var="forward" value="newPage" scope="request" />
...
<c:set var="test" value="true" scope="request" />

这将包含在主布局的某处。然而,似乎这些不会通过 a or a or a

持续存在

他们好像没听懂 "compiled"(不知道这个词对不对)

所以在我的 mainLayout.jsp

<jsp:include page="testPageVars.jsp"/>
<c:if test="${test == 'true'}>
   TEST WORKED
</c:if>

不起作用。

关于如何获得我想要的效果有什么想法吗? 目前我想出的唯一解决方案是将这些值移动到 Java(我正在使用struts) 并将它们放在那里。这并没有像我想要的那样扩展。

编辑

方块-def.xml

<definition name="main.layout" path="/jsp/mainLayout.jsp">
        <put name="actionVars" value="/jsp/testVars.jsp"/>
    </definition>

mainLayout.jsp

    <tiles:insert attribute="actionVars"/>
    <c:if test="${test == 'true'}">
       TRUE TWICE
    </c:if>

testVars.jsp

<c:set var="test" value="true" scope="request"/>
<c:if test="${test == 'true'}">
    TRUE
</c:if>

忘记在 var 文件中添加标签库。