使用 JSP include 指令传递参数
我需要使用 JSP include 指令将参数传递到页面,请在下面找到我的代码:
<script>
var gTIID
function showPlayerList(pTIID)
{
gTIID=pTIID;
$("#IdtournamentMessageMain").hide();
$("#userListFrame").show();
}
</script>
<%@ include file="players_list.jsp" %>
如何将 gTIID 传递到players_list.jsp 页面中的players_list.jsp gTTID 名为 tiID (/player_list.htm?tiID=gTIID) ?
提前致谢!
I need to pass a parameter to a page using JSP include directive find my code below:
<script>
var gTIID
function showPlayerList(pTIID)
{
gTIID=pTIID;
$("#IdtournamentMessageMain").hide();
$("#userListFrame").show();
}
</script>
<%@ include file="players_list.jsp" %>
How can I pass gTIID to players_list.jsp in the players_list.jsp page gTTID is named tiID (/player_list.htm?tiID=gTIID) ?
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
由于您正在使用
指令,因此gTIID
应该已经可用。或者,您可以将它们设置在其中一个范围(请求、会话、应用程序)中,然后从其他 JSP 中的同一范围中获取。
或者,您也可以使用
和
来实现此目的。since you are using the
<include>
directive,gTIID
should already be available.Alternately, you could set them in one of the scopes (request, session, application) and then fetch from the same scope in your other JSP.
Or, you could also use
<jsp:include>
and<jsp:param>
to achieve this.您将能够访问
players_list.jsp
中的gTIID
。无需将其作为参数传递,因为它是全局范围定义的变量。但是,请考虑到该变量仅在包含页面中定义和初始化,而不是在players.jsp 中定义和初始化。如果该页面在其他地方被引用,则可能未声明。You'll be able to acces
gTIID
inplayers_list.jsp
. There's no need to pass it as a parameter, as it's a global-scope defined variable. However, take into account that the variable is only defined and initialized in the including page, notplayers.jsp
. If that page is referenced somewhere else, it may be undeclared.我使用“players_list.jsp”页面中初始化为-1的隐藏输入框(id =“tidhide”)解决了该问题,并将其设置在showplayer函数中,在下面找到我的代码片段:
父页面:
再见!
I solved the issue using an hidden input box(id="tidhide") in the "players_list.jsp page initialized to -1 and I set it in the showplayer function, find my snippet code below:
Parent page:
bye!