/**
* 验证码
*
* @author:kris
* @Date:2022/7/1821:46
**/
@Controller
public class CapthaController {
/**
* 返回验证码字符串
*/
private String result;
@RequestMapping("/captcha")
public String captcha(HttpServletRequest request,
HttpServletResponse response) throws Exception {
// 英文
SpecCaptcha captcha = new SpecCaptcha();
captcha.setCharType(Captcha.TYPE_ONLY_LOWER);
// 长度
captcha.setLen(4);
result = captcha.text();
captcha.out(response.getOutputStream());
return result;
}
public String getResult() {
return result;
}
}
captcha验证码
最新推荐文章于 2024-08-09 07:14:19 发布