摘要: 服务器端创建session,并向浏览器发送相应的JSESSIONID,当浏览器的cookie里含有JSESSIONID时,它发起的请求就会附带这个JSESSIONID,服务器就可以根据这个JSESSIONID来匹配相应的session。关闭浏览器后JSESSIONID即被销毁。 @WebServle 阅读全文
posted @ 2020-09-21 21:09 山下明明子 阅读(147) 评论(0) 推荐(0) 编辑
摘要: 当请求带cookie时, 可通过 req.getCookies 的方法获取cookie, 获取到的是一个 cookie 数组, 可遍历获取其值: @WebServlet(name = "GetCookie") public class GetCookie extends HttpServlet { 阅读全文
posted @ 2020-09-21 16:44 山下明明子 阅读(535) 评论(0) 推荐(0) 编辑
摘要: 使用servlet设置cookie, 一次设置一个cookie, 多个cookie可以多次设置 @WebServlet(name = "TestCookie") public class TestCookie extends HttpServlet { @Override protected voi 阅读全文
posted @ 2020-09-21 15:36 山下明明子 阅读(254) 评论(0) 推荐(0) 编辑