catch와return

793 단어 DAO
프로젝트가 시작되기 전에 매니저는catch 블록에서return이 어떤 효과인지 언급한 적이 있다. 그는 당시에 분명히 말하지 않고 우리더러 스스로 시험하라고 했다.
 

try {
			String oid = abc.getId();
			ABC abc = service.get(oid);//  service      DAO     ,    DAOException
			request.setAttribute("abc", abc);
		} catch (DAOException e) {
			logger.error(e.getMessage());
			request.setAttribute("message", "!@#$");
			return mapping.findForward("error");
		} catch (Exception e) {
			logger.error(e.getMessage());
			e.printStackTrace();
			request.setAttribute("message", "!@#$");
			return mapping.findForward("error");
		}

DAO에 이상이 생기면 첫 번째catch 블록에서 이상이 끝나고 두 번째catch 블록에 잡히지 않습니다

좋은 웹페이지 즐겨찾기