[Week5] 나호준 - 컨트롤러 확장#118
Open
Rojojun wants to merge 4 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
고민사항
아래와 같이 흐름을 정의하고 진행을 했는데, 아래의 방식의 흐름이 맞는지 정확하게 잘 모르겠습니다.
부트스트랩 단계
flowchart TB subgraph App["App (com.diy.app)"] LC["LectureController<br/>@Controller"] LR["LectureRepository<br/>@Repository"] RM["메서드<br/>@RequestMapping"] end subgraph Framework["Framework (com.diy.framework)"] BS["BeanScanner<br/>(Reflections)"] AC["ApplicationContext<br/>beans: List<Object>"] RHI["RequestHandlerImpl<br/>handlers: Map<RequestKey, HandleMethod>"] end Main(["Main.main()"]) Main -->|"1. initialize()"| AC AC -->|"2. scan"| BS BS -->|"@Controller, @Component,<br/>@Repository 클래스 수집"| AC LC -.->|어노테이션 감지| BS LR -.->|어노테이션 감지| BS Main -->|"3. registerRequestMapping()"| RHI RHI -->|"4. @RequestMapping 메서드 스캔"| BS RM -.->|어노테이션 감지| BS RHI -->|"5. 메서드의 declaringClass가<br/>Controller인지 검증"| AC RHI -->|"6. RequestKey → HandleMethod<br/>맵에 등록"| RHI classDef app fill:#e3f2fd,stroke:#1976d2 classDef fw fill:#fff3e0,stroke:#f57c00 class LC,LR,RM app class BS,AC,RHI fw유저 요청 단계
sequenceDiagram actor User as 유저 (브라우저) participant Tomcat as TomcatWebServer participant Dispatcher as DispatcherServlet<br/>(프레임워크) participant Handlers as handlers Map<br/>(RequestKey→Handler) participant Controller as LectureController<br/>(App) participant Resolver as ViewResolver participant View as View<br/>(JSP/Redirect) User->>Tomcat: GET /lectures Tomcat->>Dispatcher: service(req, resp) Note over Dispatcher: App이 전체 처리를<br/>프레임워크에 위임 Dispatcher->>Dispatcher: new RequestKey(URI, Method) Dispatcher->>Handlers: get(requestKey) Handlers-->>Dispatcher: RequestHandler Dispatcher->>Controller: handler.handleRequest(req, resp)<br/>= method.invoke(bean, ...) Controller-->>Dispatcher: ModelAndView Dispatcher->>Resolver: resolveViewName(viewName) Resolver-->>Dispatcher: View Dispatcher->>View: render(model, req, resp) View->>Tomcat: HTML 응답 작성 Tomcat-->>User: HTML 페이지 표시이런 흐름이 맞다면, 컨트롤러는 결국 항상 ModelAndView를 반환하는게 옳은가 하는 고민도 생깁니다.
블로커
@RequestMapping에서 왜 RequestMethod는 어레이로 받나요?! 실제 스프링도 그렇던데, 명확한 이유를 문서로서 찾지 못해서 궁금합니다.