[英]how to assign javascript value to jsp variable in jsp page
I have a text field, I need to send these text value to the same page which is in jsp . 我有一个文本字段,我需要将这些文本值发送到jsp中的同一页面。
I just want to assign javascript value to jsp variable. 我只想将javascript值赋给jsp变量。
You could set a hidden field. 您可以设置隐藏字段。
Put this in your JSP form: 把它放在你的JSP表单中:
<input type="hidden" id="foo" name="foo" />
Execute this script whenever you want to fill the field: 只要您想填写该字段,请执行此脚本:
document.getElementById("foo").value = "some value";
When you submit the form, it'll be available as follows in the servlet: 提交表单时,它将在servlet中按如下方式提供:
String foo = request.getParameter("foo"); // "some value"
// ...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.