无法读取JSP中的请求参数

问题描述 投票:0回答:1

我在 JavaScript 中创建了一个变量。

var str = "";

在Js函数中,我成功存储了羽毛笔编辑器的内容并使用

将其打印到控制台
str = quill.container.innerHTML;
console.log(typeof(str));

在同一个js函数中,我尝试使用

将羽毛笔数据从一个jsp发送到另一个jsp
xhr_vdata.open("GET", "http://localhost:9999/report_generation_application/client_data_processing.jsp?str="+encodeURIComponent(str), true);

这里 client_data_processing.jsp 是我尝试向其发送数据的 jsp 页面。 client_data_processing.jsp 由以下服务器端代码组成,用于处理数据。

<%
String steps_to_reproduce = request.getParameter("str");
System.out.println(steps_to_reproduce);
%>

这里我无法打印鹅毛笔编辑器的内容,数据没有在服务器端读取。

javascript ajax jsp
1个回答
0
投票

问题出在您尝试使用

XMLHttpRequest()
调用的 JSP 中。 sriptlet 代码将不起作用,因为它会编译为 JSP 错误,并向调用者返回 500 状态代码。你看不到它是因为你还没有写回调错误函数。您应该检查服务器日志中是否有 JSP 错误。如果你想将内容写入响应并在成功回调函数中读取它,那么你可以使用

${param.str}
© www.soinside.com 2019 - 2024. All rights reserved.