当幸福来敲门

我就会牢牢抓住!
随笔 - 50, 文章 - 3, 评论 - 8, 引用 - 0
数据加载中……

关于登录界面 记住用户名和密码的一段代码

Cookie cookies[]=request.getCookies();
    Cookie stCookie=null;
    String password=null;
    String passwordvalue=null;
    String usernamevalue=null;
    String cookiename = null;
    String nameandpassword[]=new String[3];
    if (cookies != null) {
   for (int i = 0; i < cookies.length; i++) {
    stCookie = cookies[i];
    cookiename = stCookie.getName();
    if (cookiename!=null && cookiename.equalsIgnoreCase("db_password")) {
     passwordvalue = stCookie.getValue();
     password = passwordvalue;//.substring(8, passwordvalue.length()-3);
     nameandpassword[1] = password.trim();
    }
    if (cookiename!=null && cookiename.equalsIgnoreCase("db_username")) {
     usernamevalue = stCookie.getValue();
     nameandpassword[0] = usernamevalue.trim();
    }
    }
 }





<body>
<p>
       <label for="LoginName">
        用户名 / 邮箱:
       </label>
       <input class="text" type="text" id="LoginName" name="LoginName"
        value="<%=nameandpassword[0]==null?"":nameandpassword[0] %>" />
      </p>
      <p>
       <label for="Password">
        密码:
       </label>
       <input class="text" type="password" value="<%=nameandpassword[1]==null?"":nameandpassword[1] %>" name="Password" id="Password" />
      </p>


</body>

posted on 2013-11-01 15:08 wyx 阅读(308) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航: