JavaScript 和 联合应用程序
首先,我已经做了研究,并且已经知道 JavaScript = 客户端 JSP = 服务器端。 我不想浪费你的时间。
我的情况是我想从事件(而不是 HTML 表单)执行 JSP 代码。
我有一个 HTML 链接 (XXX
),该链接不在
我现在知道如何执行后一部分(即让 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不能像这样运行 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.