首頁  >  文章  >  Java  >  PlayFramework完整實作一個APP(七)

PlayFramework完整實作一個APP(七)

黄舟
黄舟原創
2016-12-23 16:42:551360瀏覽

1.新增驗證碼

application Controller新增captcha()

public static void captcha() {
Images.Captcha captcha = Images.captcha();
rages.Captcha captcha = Images.captcha();? Route

GET     /captcha                              cha

驗證碼圖片已經實現了,現在需要做的是驗證輸入資訊與驗證碼一致

修改captcha()方法

public static void captcha(String id) {

Images.Captcha captcha = Images.captcha(); String code = captcha.getText("#E4EAFD"); code, "10mn"); renderBinary(captcha);

}

PlayFramework完整實作一個APP(七)

  

修改show()方法

public static void show(Long id) {

 omID = Codec.UUID();
   render(post, randomID);
}


  

修改show.html頁

"content">Your message:

       

   

   


   


   


lab code">Please type the code below:
    PlayFramework完整實作一個APP(七)
   

  

   

   

="submit" value="Submit your comment" />

   

  

2.驗證

vpostComment or is required") String author,
@Required(message="A message is required") String content,
@Required(message="Please type the code") String code,
String randomId) {
post. findById(postId);
   validation.equals(code, Cache.get(randomId)).message("Invalid code. Please type it again");
   
  has it again");
我show.html", post);
   }
   

   post.addComment(author, content);    Flash.success("Thanks for posting %s",    Flash.success("Thanks for posting %s", 1horhor);

}

  

修改show.html頁


  #{ifErrors}
       

c   


   #{/ifErrors}


 

 以上就是PlayFramework完整實現一個APP(七)的內容,更多相關內容請關注PHP中文網(www.php.cn)! 



陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn