Created
November 13, 2012 14:51
-
-
Save hongsw/4066122 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package controllers; | |
import org.apache.commons.codec.digest.DigestUtils; | |
생략 | |
public class Application extends Controller { | |
final static Form<Guestbook> guestbookForm = form(Guestbook.class); | |
public static Result index() { | |
return ok(index.render(Guestbook.find.all();)); | |
} | |
public static Result write() { | |
return ok(write.render(guestbookForm)); | |
} | |
public static Result doWrite() { | |
Form<Guestbook> guestbookForm = form(Guestbook.class).bindFromRequest(); | |
if(guestbookForm.hasErrors()){ | |
return ok(write.render(guestbookForm)); | |
} | |
Guestbook gb = guestbookForm.get(); | |
gb.password = DigestUtils.md5Hex( gb.password ); | |
gb.postAt = new Date(); | |
gb.save(); | |
flash("success", "방명록이 등록 되었습니다."); | |
return redirect(routes.Application.index()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment