1.录入手机号码
2.当录入手机号码正确的时候,可以点击获取短信
3.点击获取短信,完成发短信操作
4.点击提交完成手机操作认证
5.点击提交后,我么你在后台需要做的是在数据库中将用户的手机号改成刚刚认证的号码 将用户的手机号认证状态改为1.
手机认证的实现:
1.第一当我们录入手机号
2.点击获取短信时,向服务器端发送请求,进入到后台实现发送短信操作。
@Namespace("/verification")
@Controller
@Scope("prototype")
public classVerificationAction extends BaseAction{
@Autowired
private BaseCacheService baseCacheService;
//发送短信验证码操作
@Action("sendMessage")
public void sendMessage(){
// 1.得到电话号码
String phone = this.getRquest().getParameter("phone");
//2.调用发送短信工具,发送短信
String randomNumberic = RondomStringUtils.randomNumeric(6);//随机得到6位数
String content ="请管理好您的验证码,切勿泄露验证码:"+ randomNumberic;
try{
MSMUtils.SendSms(phone,content);
}catch(UnsuportedEncodingException e){
e.printStackTrace();
}
System.out.println("向:"+phone+"发送验证信息"+content);
3.存储到redis中
baseCacheService.set(phone,randomNumeric);
baseCacheService.expire(phone,3*60);
}
}