编程语言
首页 > 编程语言> > Educoder Java生成验证码

Educoder Java生成验证码

作者:互联网

01

复制粘贴没难度, 过不去就是敲错了...

02

        PrintWriter writer = resp.getWriter();
        String verifycode = req.getParameter("verifycode");
        String username = req.getParameter("username");
        String password = req.getParameter("password");
        HttpSession session =req.getSession();
        String realCode = (String) session.getAttribute("sessionYzm");

        if(!verifycode.equals(realCode)){
            writer.write("验证码错误");
        }else{
            // writer.write("验证码正确");
            if(username.equals("admin") && password.equals("admin123")){
                writer.write("登录成功");
            }else{
                writer.write("登录失败");
            }
        }

03

        PrintWriter writer = resp.getWriter();
       HttpSession session = req.getSession();
       String trueCaptcha = (String)session.getAttribute(Constants.KAPTCHA_SESSION_KEY);
       String inputCaptcha = req.getParameter("captcha");
       if(trueCaptcha.toLowerCase().equals(inputCaptcha.toLowerCase())) {
           writer.write("验证码输入正确");
       } else {
           writer.write("验证码输入错误");
       }

还有个文件同 01, 复制粘贴没难度

N/A

本来想发评论区的, 发现还要实名... 算了

标签:Educoder,Java,String,req,writer,验证码,getParameter,write
来源: https://www.cnblogs.com/QGJHWm9DZwo/p/16334231.html