我想将查询字符串从一个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>


Second.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>


添加方法=“ post”隐藏查询字符串,即,如果我删除'method =“ post”',则按下提交按钮时处理的网址将具有
以下作为查询字符串


  uid =“无论我在文本字段中写什么”&pass =“”&login =“提交”


但是在写完“ method =“ post”'之后,新的URL将没有查询字符串...!

09-04 11:13
查看更多