为什么我最初的时候是个东西?不是空的?

来源:6-4 案例:Cookie在登录中的应用

qq_独行者Night_0

2017-06-18 21:37

http://img.mukewang.com/594681e900015bec04030213.jpg

<%@ page language="java" contentType="text/html; charset=utf-8"

    pageEncoding="utf-8"%>

<%@ page import="java.net.*" %>

<!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=utf-8">

<title>Insert title here</title>

</head>

<body>

<%

request.setCharacterEncoding("utf-8");


String username="";

String password="";

Cookie[] cookies=request.getCookies();

if(cookies!=null&&cookies.length>0){

for(Cookie c:cookies){

if(c.getName().equals("username")){

username=URLDecoder.decode(c.getValue(),"utf-8");

}

if(c.getName().equals("password")){

password=c.getValue();password=URLDecoder.decode(c.getValue(),"utf-8");

}

}

}

%>

<form action="loginOn.jsp" method="post" name="form">

<table>

<tr>

<td>User:

</td>

<td><input name="username" type="text" value="<%=username %>>" />

</td>

</tr>

<tr>

<td>Password:

</td>

<td><input name="password" type="password" value="<%=password %>>" />

</td>

</tr>

<tr>

<td colspan="2" ><input name="isUseCookie" type="checkbox" />是否保存账号信息

</td>

</tr>

<tr>

<td colspan="2"><input type="submit" value="登陆"/>

</td>

</tr>

</table>

</form>

</body>

</html>


写回答 关注

1回答

  • qq_独行者Night_0
    2017-06-18 21:41:13

    找出来了!!!手贱加了个>我靠

JAVA遇见HTML——JSP篇

Java Web入门级教程JSP,带你轻松的学习JSP基础知识

248277 学习 · 3071 问题

查看课程

相似问题