第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定

中文亂碼問題(請問為啥為設(shè)置了字符編碼為utf-8,但是username的時(shí)候還是亂碼了)

<%@ 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>


正在回答

3 回答

username = URLEncoder.encode(cookie.getValue(),"utf-8"); ??

試一下username = URLDecoder.decode(cookie.getValue(),'utf-8');

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

Zhao_Tenfe 提問者

謝謝,不過還是亂碼,一樣的
2016-11-17 回復(fù) 有任何疑惑可以回復(fù)我~
#2

Zhao_Tenfe 提問者

非常感謝!是這個(gè)原因
2016-11-17 回復(fù) 有任何疑惑可以回復(fù)我~

我的也是 ,你怎么解決的

0 回復(fù) 有任何疑惑可以回復(fù)我~
#1

Zhao_Tenfe 提問者

username = URLEncoder.encode(cookie.getValue(),"utf-8"); 試一下username = URLDecoder.decode(cookie.getValue(),'utf-8');
2016-11-19 回復(fù) 有任何疑惑可以回復(fù)我~

沒事的

0 回復(fù) 有任何疑惑可以回復(fù)我~

舉報(bào)

0/150
提交
取消

中文亂碼問題(請問為啥為設(shè)置了字符編碼為utf-8,但是username的時(shí)候還是亂碼了)

我要回答 關(guān)注問題
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號