運行以后登錄界面出現了這個
沒有輸入任何東西,編完代碼后登錄網頁用戶名和密碼就出現了這個。
login.jsp代碼:
?<body>
? <%
? ? String username ="";
? ? String password ="";
? ? Cookie[] cookies = request.getCookies();
? ? ? ? if(cookies != null&&cookies.length>0)
? ? {
? ? for (Cookie c:cookies)
? ? {
? ? if(c.getName().equals("username"))
? ? {
? ? username=c.getValue();
? ? if(c.getName().equals("password"))
? ? password=c.getValue();
? ? }
? ? }
? ? }
? %>
? ?<h1>用戶登錄</h1>
? ?<form name="loginForm" action="dologin.jsp" method="post">
? ? ?<table>
? ? ? ?<tr>
? ? ? ? ?<td>用戶名:</td>
? ? ? ? ?<td><input type="text" name="username" value=<%=username%>/></td>
? ? ? ?</tr>
? ? ? ?<tr>
? ? ? ? ?<td>密碼:</td>
? ? ? ? ?<td><input type="password" name="password" value=<%=password%>/></td>
? ? ? ?</tr>
? ? ? ?<tr>
? ? ? ? ?<td colspan="2"><input type="checkbox" name="isUseCookies" checked="checked"/>十天內記住我的登錄狀態</td></tr>
? ? ? ?<tr>
? ? ? ? ?<td colspan="2" align="center" ><input type="submit" value="登錄"/><input type="reset" value="取消"/></td></tr>
? ? ?</table>
? ? </form>
? </body>
2016-10-16
name="username" value="<%=username %>"
2016-07-27
?<td><input type="text" name="username" value=<%=username%>/></td>
? ? ? ?</tr>
? ? ? ?<tr>
? ? ? ? ?<td>密碼:</td>
? ? ? ? ?<td><input type="password" name="password" value=<%=password%>/></td>
? ? ? ?</tr>
input標簽的value屬性的屬性值需要引號括起來,注意是value="屬性值"
2016-07-18
你取消勾選十天內記錄登陸狀態登陸,然后再回到這個頁面上試試看還在不在