一、会话与状态管理
注:设置Cookie的作用路径:
<!-- Cookie作用范围:可以作用当前目录和当前目录的子目录,但不能作用于当前目录的上一级目录。 -->
<!-- 可以通过setPath方法来设置Cookie的作用范围,其中/代表站点的根目录 -->
Cookie cookie = new Cookie("cookiePath","CookiePathValue");
cookie.setPath(request.getContextPath());
response.addCookie(cookie);