ホームページ  >  記事  >  Java  >  PlayFramework は APP を完全に実装します (7)

PlayFramework は APP を完全に実装します (7)

黄舟
黄舟オリジナル
2016-12-23 16:42:551360ブラウズ

1. 確認コードを追加

application Controller add captcha()

public static void captcha() {
Images.Captcha captcha = Images.captcha();
renderBinary(captcha);
}

ルートを追加

GET /captcha 検証コード画像が実装されました。ここで行う必要があるのは、入力情報が検証コードと一致していることを確認することです

captcha() メソッドを変更します

public static void captcha(String id) {

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

renderBinary(captcha);

}PlayFramework は APP を完全に実装します (7)

show()メソッドを変更します

public static void show(Long id) {
Post post = Post.findById(id);
String randomID + for="content">メッセージ: > ;
" " ;p>

PlayFramework は APP を完全に実装します (7)
< ;br /> ;

Verify

postCommentメソッドを変更


public static void postComment(
長い postId、
@Required(message="作成者が必要です") 文字列の作成者、
@Required(message= "メッセージが必要です") String content,
@ Required(message="コードを入力してください") String code,

String randomId) {

投稿 post = Post.findById(postId);

validation.equals(code, Cache .get(randomId)).message("無効なコードです。もう一度入力してください");

if(validation.hasErrors()) {

render("Application/show.html", post);

}


post .addComment(author, content); Flash.success( "%s を投稿してくれてありがとう", author);
Cache.delete(randomId);
show(postId);
}




show.html ページを変更する

#{ifErrors}


${errors[0]} Net (www.php.cn)!

声明:
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。