蓝色是保存cookie保存密码账号
红色是读取回显密码账号
<%@ page contentType=“text/html; charset=utf-8” language=“java” import=“java.sql.*” errorPage="" %>
<!doctype html>
<%
String username = “”;
String password = “”;
String s;
Cookie [] cookies =request.getCookies();
for (Cookie cookie:cookies) {
s=cookie.getName(); //通过getName方法获得cookie的名称
if (s.equals(“username”)) {
if (cookie.getValue()!=null) {
username=username+cookie.getValue(); //通过getValue方法获得cookie的值
}} else if (s.equals(“password”)) {
if (cookie.getValue()!=null) {
password=password+cookie.getValue();
}}}
%>
test
<input name=“yhm” value="<%=username %>" style=" background:url(…/img/user.jpg) no-repeat 0 0;
background-position: 10px 5px;padding-left: 60px;font-size: 18px;" type=“text”>
<input name=“pas” value="<%=password %>" style=" background:url(…/img/pass.jpg) no-repeat 0 0;
background-position: 10px 5px;padding-left: 60px;font-size: 18px;" type=“password”>
<input style=“width: 20px; height: 20px; vertical-align: middle; margin-top: -5px;”
type=“checkbox” id=“rember”>记住用户名和密码