JavaScript 和 联合应用程序

发布于 2024-07-20 13:45:44 字数 455 浏览 1 评论 0原文

首先,我已经做了研究,并且已经知道 JavaScript = 客户端 JSP = 服务器端。 我不想浪费你的时间。

我的情况是我想从事件(而不是 HTML 表单)执行 JSP 代码。

我有一个 HTML 链接 (XXX),该链接不在

标记内; 它只是一个普通的 HTML 链接。 通过 Javascript,我将能够获取 href 值并将其存储在隐藏的输入字段中。 此后立即执行 request.getAttribute("...") 并在 JSP 页面之间传递参数。

我现在知道如何执行后一部分(即让 request.getAttribute 代码在 Javascript 代码执行后立即继续。

任何人都可以建议吗?

Firstly, I have done my research and already know that JavaScript = client JSPs = server side. I don't want to waste your time.

My situation is that I want to execute JSP code from an event (not from a HTML form).

I have a HTML link (<a href="...">XXX</a>), which is NOT within <form> tags; it just an ordinary HTML link. Through Javascript, I will be able to get the href value and store it in a hidden input field. Instantly after this, I want to execute request.getAttribute("...") and pass the parameter between JSP pages.

I do now know how to do the latter part (i.e. getting the request.getAttribute code to instantly proceed after the Javascript code has executed.

Can anyone advise?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

暗喜 2024-07-27 13:45:44

您不能像这样运行 JSP 代码。

正如您所说,JSP 代码在服务器端运行,因此您无法真正从 Web 浏览器触发它。

如果您只是尝试在 JSP 页面之间传递参数,则可以在调用第二个 JSP 时将参数添加到 URL 的 queryString 中,并在其中使用 request.getAttribute()。

请记住,JSP 代码在页面发送到浏览器之前执行。

我希望这有帮助。

You can't run JSP code like this.

JSP code, as you said is run on the server side, so you can't really trigger it from the web browser.

If you are just trying to pass a parameter between JSP pages, you can add the parameter to the queryString of the URL when you call the second JSP, and within it use request.getAttribute().

Remember, JSP code is executed before the page is sent to the browser.

I hope this helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文