学到一个可以存储账号密码的方法

发布时间 2023-11-28 22:33:41作者: 牟兆迪
// 登录成功后,将用户名存储在 HttpSession 中
HttpSession session = request.getSession();
session.setAttribute("username", username); // 假设这里的 username 是登录成功的用户名


// 在后续页面中获取保存在 HttpSession 中的用户名
HttpSession session = request.getSession();
String username = (String) session.getAttribute("username");