发表于: 2018-05-20 20:16:49

1 1353


今天完成的事情:

整合了前面的文件上传和手机验证码登陆的代码和页面:

//手机号码验证输入跳转
@RequestMapping(value = "/phoneinfo")
public String phoneinfo() {

return  "registerform";
}
//手机号码验证
@RequestMapping(value = "/phonenum", method = RequestMethod.POST,produces ={"application/json;charset=UTF-8"})
@ResponseBody
public String phonenum(String phonenum) {
verificationCodeCreater codeCreater=new verificationCodeCreater();
   codeCreater.setCode();
   int vcode=codeCreater.getCode();
   String code=smsService.smssend(phonenum,vcode);
   if(code!=null&code.equals("OK")){
redisCacheUtil.hset("telephone",phonenum,vcode,300);
       return JSON.toJSONString("发送成功");
   }
return  JSON.toJSONString("发送失败");
}

//注册是否成功
@RequestMapping(value = "/infovalida")
public String infovalida(Model model, Register register,MultipartFile file ,HttpServletRequest request,
                        String phonenum,int vcode) {
String path = request.getSession().getServletContext().getRealPath("/files");
   String fileName=file.getOriginalFilename();
   System.out.println(path);
   File targetFile = new File(path, fileName);
   if (!targetFile.exists()) {
targetFile.mkdirs();
   }
try {
file.transferTo( targetFile);
   } catch (IOException e) {
e.printStackTrace();
   }
int s=redisCacheUtil.hget("telephone",phonenum);
   boolean p=redisCacheUtil.hexists("telephone",phonenum);
   if (redisCacheUtil.hexists("telephone",phonenum)&&redisCacheUtil.hget("telephone",phonenum).equals(vcode)){
model.addAttribute("a","手机验证成功");
       String b = loginServiceImpl.register(register,targetFile);
       model.addAttribute("b", b+"=注册成功");
       return "register";
   }else{
model.addAttribute("a","手机验证失败");

       model.addAttribute("b", "=注册失败");
       return "register";
   }

搞了个页面修改,方便测试:

出现了问题,点击注册没用,验证码可以用。

调到晚上还没搞好,自己写了个简单的,

注册成功。

明天计划的事情:

 邮件还没搞好,先不贴了
遇到的问题:

阿里云短信服务有个流量限制,发了5条短信之后一直报错。不能多发,只能换accessKey.
收获:

整合了前面的代码和页面


返回列表 返回列表
评论

    分享到