Zhao_Tenfe
2016-11-17 14:44
<%@ page language="java" import="java.net.*,java.util.*" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<!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>主页</title>
</head>
<body>
<h1>用户登录</h1>
<hr>
<%
request.setCharacterEncoding("utf-8");
String username="";
String password="";
Cookie[] cookies = request.getCookies();
if(cookies != null && cookies.length > 0){
for(Cookie cookie:cookies){
if(cookie.getName().equals("username")){
username = URLEncoder.encode(cookie.getValue(),"utf-8");
}
if(cookie.getName().equals("password")){
password = URLEncoder.encode(cookie.getValue(),"utf-8");
}
}
}
%>
<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="remenber" checked="checked"/>记住密码</td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="登录"></td>
</tr>
</table>
</form>
</html>
username = URLEncoder.encode(cookie.getValue(),"utf-8");
试一下username = URLDecoder.decode(cookie.getValue(),'utf-8');
我的也是 ,你怎么解决的
没事的
JAVA遇见HTML——JSP篇
248277 学习 · 3071 问题
相似问题