2017-01-10 37 views
0

成功输入用户名和密码后,我有一个用户名和密码登录页面,它转发到登录控制器。 我的问题是,当转发到下一页时,在URL中显示密码输入。我需要加密并通过控制器发送,并且必须解密通过控制器。加密密码

这是我的代码。

的jsp:

<form action="Login" onsubmit="return validate1()"> 
       <h3> 
        <font color="red">username</font> 
       </h3> 
       <input type="text" name="username" id="username" /><br> 

       <h3> 
        <font color="red">password</font> 
       </h3> 
       <input type="password" name="password" id="password" /><br> <input type="submit" value="submit" /> 
      </form> 

的javascript:

<script> 
    function validate1() { 
     return validate(); 
    } 
    function validate() { 
     var isValid = true; 
     var name = document.getElementById("username").value; 
     var password = document.getElementById("password").value; 
     if (name.length == 0) { 
      isValid = false; 
      alert("Username empty"); 
     } else if (password.length == 0) { 
      isValid = false; 
      alert("Password empty"); 
     } 
     return isValid; 
    } 
</script> 

网址: http://localhost:8080/PSMS/Login?username=jay&password=jay

这里的密码是可见的,我需要对密码进行加密,并转发给控制器,其中再次我有解密该密码。

+2

一个选项是你可以使它成为post方法,所以它不会显示在URL中。 –

+3

你也应该使用https。 – anolsi

+0

在'form'中使用'method = Post',它不会在URL中显示 –

回答

0

我认为你需要给你的表单标签添加一个属性。

<form method="post"> ...