You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
service()
먼저requestURI를 조회해서 실제 호출할 컨트롤러를 controllerMap에서 찾는다. 만약 없다면 404(SC_NOT_FOUND) 상태 코드를 반환한다.
컨트롤러를 찾고 controller.process(request, response);을 호출해서 해당 컨트롤러를 실행한다.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
MVC 프레임워크 만들기
프론트 컨트롤러 패턴 소개 - V1
FrontController 패턴 특징
"스프링 웹 MVC와 프론트 컨트롤러"
프론트 컨트롤러의 도입 - V1
회원 등록 컨트롤러 V1(MemberFormControllerV1)
회원 저장 컨트롤러 V1(MemberSaveControllerV1)
회원 목록 컨트롤러 V1(MemberListControllerV1)
결과
FrontControllerServletV1
결과
"흐름정리"
"NotFound"
결과
프론트 컨트롤러 분석
urlPatterns
urlPatterns = "/front-controller/v1/*":/front-controller/v1를 포함한 하위 모든 요청은 이 서블릿에서 받아들인다./front-controller/v1,/front-controller/v1/a,/front-controller/v1/a/bcontrollerMap
service()
먼저
requestURI를 조회해서 실제 호출할 컨트롤러를controllerMap에서 찾는다. 만약 없다면 404(SC_NOT_FOUND) 상태 코드를 반환한다.컨트롤러를 찾고
controller.process(request, response);을 호출해서 해당 컨트롤러를 실행한다.JSP
JSP는 이전 MVC에서 사용했던 것을 그대로 사용한다
View 분리 - V2
모든 컨트롤러에서 뷰로 이동하는 부분에 중복이 있고, 깔끔하지 않다.
MyView객체를 만들어 호출한다.view 분리 - MemberFormControllerV2
view 분리 - MemberListControllerV2
view 분리 - MemberSaveControllerV2
FrontControllerServletV2
결과
흐름정리
10:50부터 ~new MyView("/WEB-INF/views/new-form.jsp")의 render 호출
MyView Class 의 viewPath의 객체에 URL값이 들어가있음
forward해서 웹브라우저로 내려감
Controller V2 classControllerV2의 반환 타입이
MyView이므로 프론트 컨트롤러는 컨트롤러의 호출 결과로Myview를 반환받는다. 그리고view.render()를 호출하면forward로직을 수행해서 JSP가 실행된다.프론트 컨트롤러의 도입으로
HyView객체의render()를 호출하는 부분을 모두 일관되게 처리할 수 있다. 각각의 컨트롤러는MyView객체를 생성만 해서 반환하면 된다.단축키
Ctrl + Alt + Shift + T: refactoring thisCtrl + Alt + N: inline VariableCtrl + Alt + VCtrl + Alt + B: Navigate > Go to Implementation(s) (옵션으로 들어감)All reactions