三国纷争
方法如下public void insertCookie(HttpServletRequest request,HttpServletResponse response, Long appId) {if (appId == null) {appId = (long) -1;}this.cleanCookie(request, response, appId);Cookie cookie = new Cookie("appId", "" + appId);cookie.setPath("/");response.addCookie(cookie);}public void cleanCookie(HttpServletRequest request,HttpServletResponse response, long appId) {Cookie[] cookies = request.getCookies();for (Cookie cookie : cookies) {if (cookie.getName().contains("" + appId)) {String cookieName = cookie.getName();Cookie newCookie = new Cookie(cookieName, null);newCookie.setPath("/");response.addCookie(newCookie);}}}