302重定向问题

qq_45822778 2020-07-11 09:27:43
我退出时访问exit能删除数据但是显示302,用户数据还在,要刷新一下页面数据就没了,怎么解决这种问题??? public void exit(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//销毁数据
// request.getSession().invalidate();
//获取所有Cookie
Cookie[] cookies = request.getCookies();
//清除所有Cookie for (Cookie c:cookies){
c.setValue(null);
c.setMaxAge(0);
System.out.println(c.getValue());
}

//重定向转到登录页面
response.sendRedirect(request.getContextPath() + "/login.html");

} public void findOne(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

//获取所有Cookie
Cookie[] cookies = request.getCookies();
//排除自带的Cookie
for (Cookie c:cookies){
if (c.getName().equalsIgnoreCase("JSESSIONID")){
c.setMaxAge(0);
c.setValue(null);
}
} if (cookies[0].getName() != null && cookies[0].getValue() != null) {
String name = cookies[0].getValue();
User user = new User();
user.setName(name);

//返回数据给客户端
writeValue(user, response);
} else {

writeValue(null, response);
}
...全文
106 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

39,087

社区成员

发帖
与我相关
我的任务
社区描述
HTML5是构建Web内容的一种语言描述方式。HTML5是互联网的下一代标准,是构建以及呈现互联网内容的一种语言方式.被认为是互联网的核心技术之一。
社区管理员
  • HTML5社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧