javascript - 如何在同一页面中将我已为 JSP 标记分配动态值的 JavaScript 变量值分配论坛提交时返回 false
问题描述
我需要为同一页面中的 JSP 分配一个 JavaScript 变量以从 JSP servlet 获取结果。请看一下代码。
function resendMail(username){
<%
String failusername = username;
%>
var redirectUrl = "https://localhost:9444/authenticationendpoint/login.do?resend_username=<%=Encode.forHtml(failusername)%>&<%=AuthenticationEndpointUtil.cleanErrorMessages(Encode.forJava(request.getQueryString()))%>";
window.location.href = redirectUrl;
}
我试过关注....我把它保存在 JSP 论坛中:
<input type="hidden" id="foo" name="foo" />
执行了这个脚本:
document.getElementById("foo").value = "some value";
我已经提交了表格(当返回 false 时):
String foo = request.getParameter("foo"); // "got null"
我也在下面尝试过
<html>
<script language="javascript" type="text/javascript">
function call(){
var name = "xyz";
window.location.replace("a.jsp?name="+name);
}
</script>
<input type="button" value="Get" onclick='call()'>
<%
String name=request.getParameter("name");
if(name!=null){
out.println(name);
}
%>
如果我使用它,上述一个工作但不适合我的情况,查询字符串正在改变,因为我遇到了问题。
只是我想在论坛提交返回 false 时将 JavaScript 变量传递给同一 Jsp 页面中的 Jsp。
任何人请帮助我提前获得解决方案谢谢
解决方案
推荐阅读
- python - 用 Python 抓取 NSE 期权链数据
- c# - Emgucv 自动裁剪检测到的形状
- c++ - 创建驱动程序以将 HID-USB 请求转换为 HCI 数据包
- python - 或多个 1d numpy.ndarray 的操作
- tensorflow.js - 打印 argMax 索引的值?
- java - Kubernetes 容器中的 Spark 看不到本地文件
- python - 使 Python 模块导入明确
- python - Django - Docker python:无法打开文件'manage.py':[Errno 2]没有这样的文件或目录
- javascript - 如何将 Google Sheet 中的唯一值传递给 HTML 电子邮件模板
- android - Firebase 电话号码 OTP 身份验证可用于在 Flutter 的 Firestore 数据库中创建用户(注册/注册)吗?如果是,如何?(安卓)