// 模拟Cookie
Cookie cookie1 = new Cookie("num", "001");
Cookie cookie2 = new Cookie("name", URLEncoder.encode("张三", "UTF-8"));
response.addCookie(cookie1);
response.addCookie(cookie2);
// 获取Cookie
Cookie[] cookies = request.getCookies();
String cookieNum = "";
String cookieName = "";
for (Cookie cookie : cookies)
{
if ("num".equals(cookie.getName()))
{
cookieNum = cookie.getValue();
}
else if ("name".equals(cookie.getName()))
{
cookieName = URLDecoder.decode(cookie.getValue(), "UTF-8");
}
Java中的cookie(3)——cookie中存取中文
最新推荐文章于 2022-10-29 00:40:24 发布