Dispatcher Servlet

MVC (Model, View, Controller) ๊ตฌ์กฐ๋กœ ๊ตฌ์„ฑ๋˜์–ด ์žˆ๋Š” Spring Framework ๋‚ด์— ์›ํ™œํ•œ ์ฒ˜๋ฆฌ๋ฅผ ์œ„ํ•œ ๊ณผ์ •์ด๋‹ค.

"Dispatcher Servlet"

๋™์ž‘ ๊ตฌ์„ฑ

  1. ํด๋ผ์ด์–ธํŠธ๊ฐ€ ์š”์ฒญํ•œ ์ •๋ณด๋ฅผ ์ตœ์ดˆ์— DispatcherServlet ์—์„œ ๊ฐ€๋กœ์ฑˆ๋‹ค.
    • web.xml ์— ๋“ฑ๋ก๋˜์–ด ์žˆ๋Š” DispatcherServlet ์˜ <url-pattern> ์ด '/' ๋กœ ๋“ฑ๋ก ๋˜์–ด ๋ชจ๋“  URL ํŒจํ„ด์— ๋™์ž‘ ๋˜๊ธฐ ๋•Œ๋ฌธ์ด๋‹ค.
    • ํŠน์ • URL ์—๋งŒ ์ ์šฉ์ด ํ•„์š”ํ•˜๋ฉด <url-pattern> ๋‚ด์šฉ์˜ ๋ฒ”์œ„๋งŒ ๋ฐ”๊ฟ”์ฃผ๋ฉด ๋œ๋‹ค.
  2. ๊ฐ€๋กœ์ฑˆ ์ •๋ณด๋ฅผ HandlerMapping ์—๊ฒŒ ๋ณด๋‚ด ํ•ด๋‹น ์š”์ฒญ์„ ์ฒ˜๋ฆฌํ•  ์ˆ˜ ์žˆ๋Š” Controller ๋ฅผ ์ฐพ์•„๋‚ธ๋‹ค.
  3. ์š”์ฒญ์„ ์ฒ˜๋ฆฌํ•  Controller ๋ฅผ ์ฐพ์•„ ๋ƒˆ์œผ๋ฉด ํ•ด๋‹น Controller ์—๊ฒŒ ํ•ด๋‹น ์š”์ฒญ ์ •๋ณด๋ฅผ ๋ณด๋‚ด์ค€๋‹ค.
  4. Controller ๋Š” ํ•ด๋‹น ์š”์ฒญ ๋‚ด์šฉ์„ ์ฒ˜๋ฆฌ ํ›„ ์š”์ฒญ์„ ์‘๋‹ต ๋ฐ›์„ View ์˜ ์ด๋ฆ„์„ ๋ฆฌํ„ดํ•˜๊ฒŒ ๋œ๋‹ค.
    • ์‹ค์ œ๋กœ ์‘๋‹ต์ „์— View Resolver ๊ฐ€ ๋ฏธ๋ฆฌ ์‘๋‹ตํ•  ๋‚ด์šฉ์„ ๋ถ„์„ํ•˜์—ฌ ํ•ด๋‹น View ์ด๋ฆ„์„ ๊ฒ€์ƒ‰ ํ•œ๋‹ค.
  5. ํ•ด๋‹น View ๊ฐ€ ์žˆ๋‹ค๋ฉด ์ฒ˜๋ฆฌ ๊ฒฐ๊ณผ๋ฅผ View ์— ๋ณด๋‚ธํ›„ ์ด ๊ฒฐ๊ณผ๋ฅผ ๋‹ค์‹œ DispatcherServlet ์— ๋ณด๋‚ธ๋‹ค.
  6. DispatcherServlet ์€ ๋ฐ›์€ ์ •๋ณด๋ฅผ ์ตœ์ข…์ ์œผ๋กœ ํด๋ผ์ด์–ธํŠธ์— ์ „์†กํ•˜๊ฒŒ ๋œ๋‹ค.

์ฐธ๊ณ ์ž๋ฃŒ

http://egloos.zum.com/springmvc/v/504151