본문 바로가기

Development/Web & Server

[Play Framework] Global Setting

Application이 아닌 Global적으로 적용하고 싶을 때 사용하면 좋다~! 


사용방법은 아주 간단하다.


최상위 루트에 Global 객체를 만들고




public class Global extends GlobalSettings {


@Override

public void onStart (final Application app) {

System.out.println("onStart");

}//end onStart Method

@Override

public void onStop (final Application app) {

System.out.println("onStop");

}//end onStop Method

@Override

public Promise<SimpleResult> onError (final RequestHeader request, final Throwable t) {

return Promise.<SimpleResult>pure(internalServerError(views.html.error.render("Error", t.toString())));

}//end onError Method

@Override

public Promise<SimpleResult> onHandlerNotFound (final RequestHeader request) {

return Promise.<SimpleResult>pure(notFound(views.html.error.render("onHandlerNotFound", request.toString())));

}//end onHandlerNotFound Method

@Override

public Promise<SimpleResult> onBadRequest (final RequestHeader request, final String error) {

return Promise.<SimpleResult>pure(badRequest(views.html.error.render("onBadRequest", error)));

}//end onBadRequest Method

}//end Global Class


위와 같이 사용면 된다.~!


자세한 사항은 여기서..