使用< jsp:include>将参数传递给另一个JSP文件标签 [英] Passing parameters to another JSP file using <jsp:include> tag

查看:90
本文介绍了使用< jsp:include>将参数传递给另一个JSP文件标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个JSP文件,在该文件中我包含另一个JSP文件:

I have a JSP file and in that file I am including another JSP file:

<c:forEach var="instanceVar" items="${instanceList}">
    <c:set var="instance"><jsp:include page="instance.jsp"/></c:set>
    ...
</c:forEach



instance.jsp 文件中,我想使用变量 instanceVar 。我想用JSTL做。有没有办法做到这一点?


In the file instance.jsp I want to use a variable instanceVar. I want to do it using JSTL. Is there any way to do this?

推荐答案

<c:forEach var="instanceVar" items="${instanceList}">
    <jsp:include page="instance.jsp">
        <jsp:param name="myVar" value="${instanceVar}"/>
    </jsp:include>
</c:forEach>

instance.jsp

<c:out value="${param.myVar}"/>

这篇关于使用&lt; jsp:include&gt;将参数传递给另一个JSP文件标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆