如何在.jsp文件中接收Ajax发送的数据 [英] How to receive data sent by Ajax in a .jsp file
本文介绍了如何在.jsp文件中接收Ajax发送的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在JQuery中使用Ajax调用将一些数据发送到JSP文件.这是代码:
I am using Ajax call in JQuery to send some data to a JSP file. Here is the code:
$.post("myscript.jsp",
{ sg: data1, st: data2 },
function(data){
alert("Data Loaded: " + data);
}
);
我的问题是,如何在myscript.jsp中接收数据? 我需要数据来在jsp中执行一些计算.
My question is, how can I receive the data in myscript.jsp? I need the data to perform some calculations in jsp.
推荐答案
您可以从请求中获取参数,例如:
You can get parameter from request like :
String data1 = request.getParameter("sg");
String data2 = request.getParameter("st");
这篇关于如何在.jsp文件中接收Ajax发送的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文