我想将查询字符串从一个 jsp 页面发送到 jsp 页面,但我想在发送查询字符串时隐藏地址栏上的名称-值对(属性)。
First.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>First Page</title>
</head>
<body>
<a href="Second.jsp?username=aditya123&password=abc12345">Click Here</a>
</body>
</html>
第二.jsp
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Second Page</title>
</head>
<body>
<%
String username = request.getParameter("username");
String password = request.getParameter("password");
%>
Username : <%=username %><br/>
Password : <%=password %><br/>
</body>
</html>
在这里,我将查询字符串 "Second.jsp?username=aditya123&password=abc12345"
从 First.jsp
页面传递到 Second.jsp
页面,但我想发送此页面而不在地址栏显示用户名和密码属性及其值。这怎么可能?
最佳答案
试试这个代码
<form action="some.jsp" method="post">
<input type="text" name="uid" >
<input type="password" name="pass">
<input type="submit" name="login" >
</form>
添加 method ="post"会隐藏查询字符串也就是说,如果我删除 'method="post"',按下提交按钮时处理后的 url 将具有 以下为查询字符串
uid="whatever i wrote in text field"&pass=""&login="Submit"
但是在写入“method="post””之后,新的网址将不再包含查询字符串...!
关于java - 如何将查询字符串从一个 jsp 页面传递到另一个 jsp 页面而不在地址栏显示名称/值对?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29181408/