JavaScript& JSP [英] JavaScript & JSP

查看:118
本文介绍了JavaScript& JSP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

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

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

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

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.

我现在知道如何做后者part(即获取request.getAttribute代码,以便在Javascript代码执行后立即继续。

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?

谢谢你,
卢卡斯

Thankyou, Lucas

推荐答案

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

You can't run JSP code like this.

如你所说的JSP代码是在服务器端运行的,因此你无法从网络浏览器中真正触发它。

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

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

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().

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

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

我希望这会有所帮助。

这篇关于JavaScript&amp; JSP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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