本文整理了Java中javax.servlet.http.Cookie.setName()
方法的一些代码示例,展示了Cookie.setName()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Cookie.setName()
方法的具体详情如下:
包路径:javax.servlet.http.Cookie
类名称:Cookie
方法名:setName
暂无
代码示例来源:origin: stackoverflow.com
Cookie cookie = new Cookie();
cookie.setName(); // setValue, setMaxAge, setPath, etc.
response.addCookie(cookie);
代码示例来源:origin: org.jvnet.hudson.winstone/winstone
public Cookie(String name, String value) {
setName(name);
setValue(value);
setMaxAge(-1);
}
代码示例来源:origin: stackoverflow.com
public void onLogoutSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication)
throws IOException, ServletException {
//This search may or may not actually be necessary, you might be able to just
// create a new cookie with the right name
for(Cookie cookie : request.getCookies()) {
if(cookie.getName() == "JSESSIONID") {
//Clear one cookie
cookie.setName("");
cookie.setMaxAge(0);
cookie.setPath(request.getContextPath());
response.addCookie(cookie);
//Clear the other cookie
Cookie cookieWithSlash = cookie.clone();
cookieWithSlash.setPath(request.getContextPath() + "/");
response.addCookie(cookieWithSlash);
}
}
//This is actually a filter; continue along the chain
super.onLogoutSuccess(request, response, authentication);
}
内容来源于网络,如有侵权,请联系作者删除!