acsii編碼(1個字節8位) 夠表示英文了,不能表示其餘國家的字 GB2312 是對 ASCII 的中文擴展。127號以前和acsii同樣 unicode表示全部字(2個字節),可是對於英文存儲翻倍。 utf-8 可變長度的編碼方案,經常使用的英文1個字節,漢字3個字節。省空間。html
首先%是由於url規範。非ASCii編碼編碼16進制後都要加%java
能夠看出Path Info 和Query String 採用不一樣的編碼。瀏覽器
參見:不一樣瀏覽器中URL的編碼方式post
<%@ page contentType="text/html;charset=UTF-8" %> 用於編碼query Stringui
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" useBodyEncodingForURI='true' URIEncoding='UTF-8' />
URIEncoding設置Path Info的解碼方式編碼
useBodyEncodingForURI設置queryString 經過header中的ContentType解碼url
編碼:瀏覽器經過ContentType charset進行編碼.net
解碼:request.setCharacterEncoding(charset)code
編碼:response.setCharacterEncoding(覆蓋request.getCharacterEncoding)編碼,並寫入Header Content-Typexml
解碼:
<meta HTTP-equiv="Content-Type" content="text/html;charset=GBK"/>
症狀:
String value = request.getParameter(name); //亂碼 String value = String(request.getParameter(name).getBytes("ISO-8859-1"),"GBK"); //正常
緣由:沒有配置useBodyEncodingForURI=true
默認使用iso-8859-1解碼,解碼後亂碼
將亂碼再編碼,在用gbk解碼獲得正確結果。