๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

MVC5

[Spring] ์š”์ฒญ ๋งคํ•‘ ํ•ธ๋“ค๋Ÿฌ ์–ด๋Žํ„ฐ์˜ ๊ตฌ์กฐ Argument Resolver ์• ๋…ธํ…Œ์ด์…˜ ๊ธฐ๋ฐ˜ ์ปจํŠธ๋กค๋Ÿฌ๋ฅผ ์ฒ˜๋ฆฌํ•˜๋Š” RequestMappingHandlerAdapter๋Š” ๋ฐ”๋กœ ์ด ArgumentResolver๋ฅผ ํ˜ธ์ถœํ•ด์„œ ์ปจํŠธ๋กค๋Ÿฌ(ํ•ธ๋“ค๋Ÿฌ)๊ฐ€ ํ•„์š”๋กœ ํ•˜๋Š” ๋‹ค์–‘ํ•œ ํŒŒ๋ผ๋ฏธํ„ฐ์˜ ๊ฐ’(๊ฐ์ฒด)๋ฅผ ์ƒ์„ฑํ•œ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ์ด๋ ‡๊ฒŒ ํŒŒ๋ผ๋ฏธํ„ฐ์˜ ๊ฐ’์ด ๋ชจ๋‘ ์ค€๋น„๋˜๋ฉด ์ปจํŠธ๋กค๋Ÿฌ๋ฅผ ํ˜ธ์ถœํ•˜๋ฉด์„œ ๊ฐ’์„ ๋„˜๊ฒจ์ค€๋‹ค. public interface HandlerMethodArgumentResolver { boolean supportsParameter(MethodParameter parameter); @Nullable Object resolveArgument(MethodParameter parameter, @Nullable ModelAndViewContainer mavContainer, Native.. 2023. 8. 8.
[Spring] ์Šคํ”„๋ง MVC ๊ตฌ์กฐ DispatcherServlet ๊ตฌ์กฐ๋ฅผ ์‚ดํŽด๋ณด์ž DispatcherServlet๋„ ๋ถ€๋ชจ ํด๋ž˜์Šค์—์„œ HttpServlet์„ ์ƒ์†๋ฐ›์•„์„œ ์‚ฌ์šฉํ•˜๊ณ , ์„œ๋ธ”๋ฆฟ์œผ๋กœ ๋™์ž‘ํ•œ๋‹ค. DispatcherServlet -> FrameworkServlet -> HttpServleBean -> HttpServlet ์Šคํ”„๋ง ๋ถ€ํŠธ๋Š” DispathcherServlet์„ ์„œ๋ธ”๋ฆฟ์œผ๋กœ ์ž๋™ ๋“ฑ๋กํ•˜๋ฉด์„œ ๋ชจ๋“  ๊ฒฝ๋กœ๋ฅผ "/"์— ๋Œ€ํ•ด์„œ ๋งคํ•‘ํ•œ๋‹ค. ํ•˜์ง€๋งŒ ๋” ์ž์„ธํ•œ ๊ฒฝ๋กœ์˜ ์šฐ์„ ์ˆœ์œ„๊ฐ€ ๋†’๋‹ค. ์š”์ฒญ ํ๋ฆ„ โœจโœจโœจ ์„œ๋ธ”๋ฆฟ์ด ํ˜ธ์ถœ๋˜๋ฉด Httpservlet์ด ์ œ๊ณตํ•˜๋Š” service()๊ฐ€ ํ˜ธ์ถœ๋œ๋‹ค. ์Šคํ”„๋ง MVC๋Š” DispathcerServlet์˜ ๋ถ€๋ชจ์ธ FrameworkServlet์—์„œ service()๋ฅผ ์˜ค๋ฒ„๋ผ์ด๋“œ ํ•ด๋‘์—ˆ๋‹ค. FrameworkServlet... 2023. 8. 7.
[Spring] ์„œ๋ธ”๋ฆฟ(servlet) aka. MVC ๊ตฌ๋ฒ„์ „ ์„œ๋ธ”๋ฆฟ์€ ์ž๋ฐ” ์–ธ์–ด๋ฅผ ๊ธฐ๋ฐ”๋Šฅ๋กœ ์›น ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ๊ฐœ๋ฐœํ•˜๋Š”๋ฐ ์‚ฌ์šฉ๋˜๋Š” ๊ธฐ์ˆ ์ด๋‹ค. ์›น ์„œ๋ฒ„์—์„œ ๋™์ž‘ํ•˜๋Š” ์ž๋ฐ” ํด๋ž˜์Šค๋กœ, ํด๋ผ์ด์–ธํŠธ์˜ ์š”์ฒญ์„ ๋ฐ›์•„ ์ฒ˜๋ฆฌํ•˜๊ณ  ๊ทธ ๊ฒฐ๊ณผ๋ฅผ ๋‹ค์‹œ ํด๋ผ์ด์–ธํŠธ์—๊ฒŒ ์ „์†กํ•˜๋Š” ์—ญํ• ์„ ์ˆ˜ํ–‰ํ•œ๋‹ค. @WebServlet : ์„œ๋ธ”๋ฆฟ ์• ๋…ธํ…Œ์ด์…˜ name : ์„œ๋ธ”๋ฆฟ ์ด๋ฆ„ urlPatterns : URL ๋งคํ•‘ ์˜ˆ ) @WebServlet(name = "helloServlet", urlPatterns = "/hello") HTTP์š”์ฒญ์„ ํ†ตํ•ด ๋งคํ•‘๋œ URL์ด ํ˜ธ์ถœ๋˜๋ฉด ์„œ๋ธ”๋ฆฟ ์ปจํ…Œ์ด๋„ˆ๋Š” ๋‹ค์Œ ๋ฉ”์„œ๋“œ๋ฅผ ์‹คํ–‰ํ•œ๋‹ค. protected void service(HttpServletRequest request, HttpServletResponse response) HttpServletRequest ์—ญํ•  HTTP ์š”์ฒญ .. 2023. 8. 3.
[Spring] ์›น ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์˜ ์ดํ•ด... ์›น์€ HTTP ๊ธฐ๋ฐ˜์œผ๋กœ ์ด๋ฃจ์–ด์ ธ์žˆ๋‹ค. ํด๋ผ์ด์–ธํŠธ์™€ ์„œ๋ฒ„๋กœ ๋‚˜๋‰˜์–ด ์žˆ๋‹ค๋Š” ๋ง์ด๋‹ค.. HTTP ๋ฉ”์‹œ์ง€๋กœ๋Š” ๋ชจ๋“  ๊ฒƒ์„ ์ „์†กํ•  ์ˆ˜ ์žˆ๋‹ค. HTML, TEXT ์ด๋ฏธ์ง€, ์Œ์„ฑ, ์˜์ƒ, ํŒŒ์ผ JSON, XML (API) ๊ฑฐ์˜ ๋ชจ๋“  ํ˜•ํƒœ์˜ ๋ฐ์ดํ„ฐ ์ „์†ก ๊ฐ€๋Šฅ ์„œ๋ฒ„๊ฐ„์— ๋ฐ์ดํ„ฐ๋ฅผ ์ฃผ๊ณ  ๋ฐ›์„ ๋•Œ๋„ ๋Œ€๋ถ€๋ถ„ HTTP ์‚ฌ์šฉ ์›น ์„œ๋ฒ„(Web Server) HTTP ๊ธฐ๋ฐ˜์œผ๋กœ ๋™์ž‘ ์ •์  ๋ฆฌ์†Œ์Šค ์ œ๊ณต, ๊ธฐํƒ€ ๋ถ€๊ฐ€๊ธฐ๋Šฅ ์ •์ (ํŒŒ์ผ) HTML, CSS, JS, ์ด๋ฏธ์ง€, ์˜์ƒ ์˜ˆ) NGINX, APACHE ์›น ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ์„œ๋ฒ„(WAS - Web Application Server) HTTP ๊ธฐ๋ฐ˜์œผ๋กœ ๋™์ž‘ ์›น ์„œ๋ฒ„ ๊ธฐ๋Šฅ ํฌํ•จ (์ •์  ๋ฆฌ์†Œ์Šค ์ œ๊ณต ๊ฐ€๋Šฅ) ํ”„๋กœ๊ทธ๋žจ ์ฝ”๋“œ๋ฅผ ์‹คํ–‰ํ•ด์„œ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๋กœ์ง ์ˆ˜ํ–‰ ๋™์  HTML, HTTP API(JSON) ์„œ๋ธ”๋ฆฟ.. 2023. 8. 1.