12.07.2015 Views

4.3.1.Action의 역할 - Anyframe

4.3.1.Action의 역할 - Anyframe

4.3.1.Action의 역할 - Anyframe

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Exception Handling12.2.DefaultBaseExceptionHandler 확장다음은 DefaultBaseExceptionHandler를 확장하여 해당 프로젝트의 Exception 처리 방식을 재정의한SampleExceptionHandler.java 이다.public class SampleExceptionHandler extends DefaultBaseExceptionHandler {}public SampleExceptionHandler() {this.defaultBundle= "anyframe.sample.struts.web.common.SampleResources";public ActionForward execute(Exception exception, ExceptionConfig config,ActionMapping mapping, ActionForm form, HttpServletRequest request,HttpServletResponse response) throws ServletException {ActionForward forward = mapping.getInputForward();if (exception instanceof AuthenticationException) {String loginPageURI = "/loginView.do";forward.setPath(loginPageURI);request.setAttribute("authenticateFail", "true");} else if (exception instanceof AuthorizationException) {String homePageURI = "/authrizationView.do";forward.setPath(homePageURI);request.setAttribute("authFail", "true");} else {String forwardPath = forward.getPath();if (forwardPath == null || forwardPath.equals("")) {forwardPath = "/loginView.do";request.setAttribute("authFail", "true");}String url = forwardPath + "?";}}Enumeration enumrequest = request.getParameterNames();while (enumrequest.hasMoreElements()) {String parameterName = (String) enumrequest.nextElement();String parameterValue = request.getParameter(parameterName);url += parameterName + "=" + parameterValue + "&";}forward.setPath(url);}request.getSession().setAttribute("afterErrorPage", forward);return super.execute(exception, config, mapping, form, request,response);에러 메시지 처리를 위한 기본 Message Resource Bundle을anyframe.sample.struts.web.common.SampleResources로 재정의하였고 이전 요청 정보를 get 방식으57

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!