1.后台代码(ssm框架)
2,Tools工具中代码
private static File checkCodefile;
public static String[] chars = new String[] { “a”, “b”, “c”, “d”, “e”, “f”, “g”, “h”, “i”, “j”, “k”, “l”, “m”, “n”, “o”, “p”, “q”, “r”, “s”, “t”, “u”, “v”,
“w”, “x”, “y”, “z”, “0”, “1”, “2”, “3”, “4”, “5”, “6”, “7”, “8”, “9”, “A”, “B”, “C”, “D”, “E”, “F”, “G”, “H”, “I”, “J”, “K”, “L”, “M”, “N”, “O”,
“P”, “Q”, “R”, “S”, “T”, “U”, “V”, “W”, “X”, “Y”, “Z” };
static {
URL uri = Tools.class.getResource("/");
checkCodefile = null;
try {
checkCodefile = new File(uri.toURI());
} catch (URISyntaxException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
String pathname = checkCodefile.getAbsolutePath() + "/CheckCode.properties";
checkCodefile = new File(pathname);
if (checkCodefile.exists()) {
try {
checkCodefile.createNewFile();
PrintStream out = new PrintStream(checkCodefile);
out.println("CheckCode="+Tools.get8UUID()); properties文件中key=value(可以有多个)
out.close();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
**以上是服务器启动的时候生成一个8位的随机数**
3.修改properties文件中的值
Tools工具类中
效果图