1. Cookie 存储在客户端
2. 创建cookie
Cookie c = new Cookie("name", "value");
3. 添加cookie
response.addCookie(c);
4. 接收cookie
Cookies[] cookies = request.getCookies();
5. for循环遍历
if (cookies != null) { for (Cookie cookie : cookies) { String name = cookie.getName(); String value = cookie.getValue(); System.out.println(name + "=" + value); }
时间: 2024-10-23 19:36:25