Skip to content

Instantly share code, notes, and snippets.

@hongsw
Created November 13, 2012 14:51
Show Gist options
  • Save hongsw/4066122 to your computer and use it in GitHub Desktop.
Save hongsw/4066122 to your computer and use it in GitHub Desktop.
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