Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/360.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何在jsp中使用超链接将文本框值传递到下一页_Java_Javascript_Jsp_Servlets - Fatal编程技术网

Java 如何在jsp中使用超链接将文本框值传递到下一页

Java 如何在jsp中使用超链接将文本框值传递到下一页,java,javascript,jsp,servlets,Java,Javascript,Jsp,Servlets,我想通过超链接在jsp中传递我的文本框值。文本框和超链接都在同一个jsp页面中。如何实现这一点使用标记&使用查询字符串将文本框的值传递给其他jsp页面 <a href="pass.jsp" onclick="addTextBoxData(this)"> <script> function addTextBoxData(e){ e.href = e.href + "?textbox=" + document.getElementById('textboxID').

我想通过超链接在jsp中传递我的文本框值。文本框和超链接都在同一个jsp页面中。如何实现这一点

使用
标记&使用
查询字符串
将文本框的值传递给其他
jsp
页面

<a href="pass.jsp" onclick="addTextBoxData(this)">

<script>
function addTextBoxData(e){
    e.href = e.href + "?textbox=" + document.getElementById('textboxID').value;
}
</script>

函数addTextBoxData(e){
e、 href=e.href+“?textbox=“+document.getElementById('textboxID')。值;
}
您只需要使用
this
传递标记的引用

然后它将附加数据
?textbox=textbox值


所以它将是
/pass.jsp?textbox=txt
您使用
GET
方法,例如,创建文件
index.jsp

<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title></title>
</head>
<body>
<form method="get" action="index.jsp">
    <table>
        <tr>
            <td><label for="txtUserName">Username: </label></td>
            <td><input type="text" id="txtUserName" name="txtUserName"/><br/></td>
        </tr>
        <tr>
            <td><label for="emailUser">Email: </label></td>
            <td><input type="email" id="emailUser" name="emailUser"></td>
        </tr>
        <tr>
            <td></td>
            <td><input type="submit" value="Submit"></td>
        </tr>
    </table>
</form>
</body>
</html>



在询问之前只需谷歌一下。。。!!!!这取决于javascript的工作/启用情况@多维的答案是更多adequate@DavidBrossard:是的。我同意你的看法,但大多数浏览器都支持Javascript。
http://localhost:8080/index.jsp?txtUserName=myname&emailUser=myname%40example.com