在子jsp中设置父jsp变量 [英] Setting parent jsp variables in child jsp

查看:162
本文介绍了在子jsp中设置父jsp变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个父级jsp a.jsp,其中包括另一个jsp b.jsp.我正在b.jsp中计算一些需要在父jsp a.jsp中使用的值,它将将该计算值传递给另一个说c.jsp的jsp.在该页面完全加载之前,如何评估子jsp中的值并将其传递给父jsp?

I have a parent jsp a.jsp which includes another jsp b.jsp. I am calculating some values in b.jsp which needs to be used in parent jsp a.jsp , which will pass this calculated value to another jsp say c.jsp. How can I evaluate value in child jsp and pass it to parent jsp before that page completely loads?

推荐答案

您如何将孩子"罐子包含在父罐中?静态还是动态导入?

How are you including the "child" jar inside the parent? static or dynamic import?

如果有

<%@ include file="myFile.jsp" %>

更改方式

<jsp:include file="myFile.jsp" />

然后在父级中为请求设置一个属性 (不在会话中,该属性为"dirdir"):

then in the parent set a property in the request (not in the session, that would be "dirtier"):

<% request.setAttribute("attrName", myValue) %>

最后,在子" jsp中:

finally, in the "child" jsp:

<% myValue = (MyValueType)request.getAttribute("attrName") %>

这篇关于在子jsp中设置父jsp变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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