【Java】【web】使用工具类实现验证码

2017-04-08  本文已影响38人  JerichoPH

使用工具类实现验证码

public class CodeImg extends HttpServlet {

    public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        // 禁止浏览器使用缓存
        response.setHeader("pragam", "no-cache");
        response.setHeader("cache-control", "no-cache");
        response.setDateHeader("expires",0);
    
        ValidateCode vc = new ValidateCode(110, 25, 4, 9);
        vc.write(response.getOutputStream());
    }
    
    public void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        this.doGet(request, response);
    }

}
上一篇下一篇

猜你喜欢

热点阅读