Java Web 在JAVA中获取SEEION中的值的方式

来源:互联网 发布:ip与mac绑定有好处吗 编辑:程序博客网 时间:2024/06/06 17:11

// 将生产的验证码保存到Session中的validate属性中
HttpSession session = req.getSession();
session.setAttribute("validate", randomCode.toString());//注意,这个验证码是大写字母组成

HttpSession httpSession =ServletActionContext.getRequest().getSession();

session.setAttribute("validate", randomCode.toString());//注意,这个验证码是大写字母组成

String vcode2= (String) httpSession.getAttribute("validate");//取得验证码类存在session中的验证码

if(p.getAsString("yzm").trim().equalsIgnoreCase(vcode2)){//先判断验证码是否输入正确

原创粉丝点击