1 首先下载ValidateCode.jar包,添加到项目中
下载链接:https://download.csdn.net/download/qq_39403545/10773564(已有的可以忽略)
2 用法简单实例
@RequestMapping("/getCode")
public void getCode(HttpServletRequest request, HttpServletResponse response) throws IOException {
//参数列表:宽度,高度,字符数,干扰线数量
ValidateCode vc = new ValidateCode(120, 30, 4, 13);
vc.write(response.getOutputStream());
String code = vc.getCode();
request.getSession().setAttribute("code", code);
}