1. 程式人生 > >發送驗證碼

發送驗證碼

是否 str else orm tint random resp new div

// 發送驗證碼
@RequestMapping(value = "sendCode")
@ResponseBody
public Object sendCode(String phone) {
Random random = new Random();
String value = String.format("%s%s%s%s%s%s", random.nextInt(10), random.nextInt(10), random.nextInt(10),
random.nextInt(10), random.nextInt(10), random.nextInt(10));
if (JuheSmsUtil.getRequest2(phone,"48733",value)) {
//發送驗證碼成功以後 要把驗證碼保存起來,登錄的時候 校驗驗證碼是否正確
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String firstTime=format.format(new Date());
logger.info("發送驗證碼:"+firstTime);
String stampValue[]=new String[2];
stampValue[0]=value;
stampValue[1]=firstTime;
map.put(phone,stampValue);
return JsonUtil.successMessage("發送成功");
} else {
return JsonUtil.failMessage("發送失敗");
}
}

發送驗證碼