RFC6265 Cookie values characters restricted to US-ASCII: 0x5468
程序员文章站
2024-03-17 11:42:28
...
Cookie中存储中文异常
今天存储cookie用户名称时发生异常
临床表现:RFC6265 Cookie values characters restricted to US-ASCII: 0x5468
Cookie默认支持的编码方式是ASCII码
治疗手段:
1.创建cookie
Cookie cookie = new Cookie(name,URLEncoder.encode(value, "UTF-8"));
2.读取cookie
String value = URLDecoder.decode(cookie.getValue(), "UTF-8");
上一篇: LeetCode-复原IP地址
下一篇: 4.JavaScript -语句