import java.util.Random; String random_len(int string_length) { chars = "ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz123456789"; randomstring =""; for (int i=0; i<string_length; i++) { Random randomGenerator = new Random(); int randomInt = randomGenerator.nextInt(chars.length()); randomstring += chars.substring(randomInt,randomInt+1); } return randomstring; } log.info("8位长度:"+random_len(8)); log.info("16位长度:"+random_len(16)); vars.put("random_8", random_len(8)); vars.put("random_16", random_len(16));