public class VerifyCodeImageUtil extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
static int |
TYPE_ALL_MIXED
验证码类型为数字和大小写字母混合
|
static int |
TYPE_LETTER_ONLY
验证码类型为仅字母,即大小写字母混合
|
static int |
TYPE_LOWER_ONLY
验证码类型为仅小写字母
|
static int |
TYPE_NUM_LOWER
验证码类型为数字和小写字母混合
|
static int |
TYPE_NUM_ONLY
验证码类型为仅数字,即0~9
|
static int |
TYPE_NUM_UPPER
验证码类型为数字和大写字母混合
|
static int |
TYPE_UPPER_ONLY
验证码类型为仅大写字母
|
| 构造器和说明 |
|---|
VerifyCodeImageUtil() |
| 限定符和类型 | 方法和说明 |
|---|---|
static BufferedImage |
generateImageCode(int type,
int length,
String excludeString,
ImageCodeProperty imageCodeProperty)
生成图片验证码
|
static BufferedImage |
generateImageCode(String textCode,
ImageCodeProperty imageCodeProperty)
已有验证码,生成验证码图片
|
static Color |
generateRandomColor()
生成随机颜色
|
static String |
generateTextCode(int type,
int length,
String excludeString)
生成验证码字符串
|
static String |
getVerifyCodeImage(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
int type,
int len,
ImageCodeProperty imageCodeProperty)
获取验证码图片和文本(验证码文本会保存在HttpSession中)
|
public static final int TYPE_NUM_ONLY
public static final int TYPE_LETTER_ONLY
public static final int TYPE_ALL_MIXED
public static final int TYPE_NUM_UPPER
public static final int TYPE_NUM_LOWER
public static final int TYPE_UPPER_ONLY
public static final int TYPE_LOWER_ONLY
public static String getVerifyCodeImage(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, int type, int len, ImageCodeProperty imageCodeProperty) throws IOException
request - response - type - len - imageCodeProperty - IOExceptionpublic static Color generateRandomColor()
public static BufferedImage generateImageCode(int type, int length, String excludeString, ImageCodeProperty imageCodeProperty)
type - 验证码类型,参见本类的静态属性length - 验证码字符长度,要求大于0的整数excludeString - 需排除的特殊字符imageCodeProperty - 验证码属性public static String generateTextCode(int type, int length, String excludeString)
type - 验证码类型,参见本类的静态属性length - 验证码长度,要求大于0的整数excludeString - 需排除的特殊字符(无需排除则为null)public static BufferedImage generateImageCode(String textCode, ImageCodeProperty imageCodeProperty)
textCode - 文本验证码imageCodeProperty - 验证码属性Copyright © 2022 Pivotal Software, Inc.. All rights reserved.