我正在使用带有HttpServletRequest和响应的Spring控制器来删除cookie.
Cookie[] allCookies = request.getCookies();
for (int i = 0; i < allCookies.length; i++)
{
String name = allCookies[i].getName();
if (name.equalsIgnoreCase("JSESSIONID"))
{
logger.info(i + " Name=" + name + " Value=" + allCookies[i].getValue());
cookieToDelete = allCookies[i];
cookieToDelete.setValue("");
cookieToDelete.setMaxAge(0);
cookieToDelete.setVersion(0);
cookieToDelete.setPath("/");
response.addCookie(cookieToDelete);
}
}
最佳答案
原文链接:https://www.f2er.com/spring/531765.html