javaweb encoding and decoding process

Reference:
https://www.ibm.com/developerworks/cn/java/j-lo-chinesecoding/#N10263
https://www.cnblogs.com/chenssy/p/4207554.html

Scenario:
JSP: <%@ page language="java" contentType="text/html; charset=uft-8" pageEncoding="utf-8"%>
Initiate a get request: window.location.href="/testWebb/testWeb ?aa="+'I I I Oh King'

1. The parameters in the url are stored in the memory as unicode (char)
2. After the get request is initiated, the browser encodes the url parameters (bytes) according to the page charset, for example: I, I, Oh, King
gbk: %CE%D2% CE%D2%CE%D2%C5%B6%CD%F5
utf8: %E6%88%91%E6%88%91%E6%88%91%E5%93%A6%E7%8E%8B (% is The url specification is added)
3. The server request
is decoded according to the content-type encoding format (bytes-char), if the content-type is not set, it will use ISO-8859-1 for decoding by default, and get unicode (char)
4. Server The response
response is encoded according to the content-type encoding format (char-bytes). If the content-type is not set, ISO-8859-1 is used for encoding by default, and bytes are obtained.
5. The browser decodes the bytes according to the page charset

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324739382&siteId=291194637