private static final String CODE = "0123456789"; /** * 生成随机字符,不含0和O,字符全为大写 * * @param length * @return */ public static String getCaptachCode(int length) { String str = ""; for (int i = 0; i < length; i++) { str = str + CODE.charAt((int) (CODE.length() * java.lang.Math.random())); } return str; }