【发布时间】:2014-09-12 15:43:24
【问题描述】:
我正在通过两个 JSP 页面发送信息,但我无法打印第二页中的信息。
function sendSuccess (dir) {
console.log(jdata);
$.ajax({
url: dir,
type: "POST",
data: jdata,
contentType: "application/json"
})
.done(function( response ) {
$("#energyQuote").hide();
$("#success_msg").html(response).fadeIn('slow');
});
}
在带有console.log 声明的谷歌浏览器中,我得到了这个:
Object {name_id: "tre", tlfono: "435", email_id: "dg@dfss.ghj", consumo_hm: "324", numFront_id0: "324"…}consumo_hm: "324"cotizac_id: "24"email_id: "dg@dfss.ghj"kva_id0: "324"name_id: "tre"numFront_id0: "324"tlfono: "435"__proto__: Object
在我用来打印的第二个 JSP 中:
<%= request.getAttribute("name_id") %>
<%= request.getParameter("name_id") %>
<%= ics.GetVar("jdata.type_Identify") %>
但我总是得到空值。
【问题讨论】:
-
首先需要解析json
-
如果您没有使用 JSON,servlet 容器会自动为您提供参数,但我想您有充分的理由这样做。只需阅读正文并解析它,但不要依赖 JSP 机器的任何帮助,因为 您 选择不使用它。