๋ฐ˜์‘ํ˜•

์–ด๋””์„œ ๋งŽ์ด ๋ณธ ๊ทธ๋ฆผ

 

 

filter
์„ค๋ช…

dispatcherServlet ํ˜ธ์ถœ ์ „, ์š”์ฒญ์— ๋Œ€ํ•ด์„œ ์ „์ฒ˜๋ฆฌ ์ž‘์—…(์›ํ•˜๋Š” ํ˜•ํƒœ๋กœ ๋ณ€ํ˜•)์ด ํ•„์š”ํ•œ ๊ฒฝ์šฐ ์‚ฌ์šฉํ•˜๋Š”๊ฒƒ. (์›น ์–ดํ”Œ๋ฆฌ์ผ€์ด์…˜์—์„œ ๋“ฑ๋ก)
filter chain ์„ ํ†ตํ•ด ์—ฐ์‡„์ ์œผ๋กœ ๋™์ž‘ํ•  ์ˆ˜ ์žˆ๊ฒŒ ๊ฐ€๋Šฅ.
์ธ์ฆ, ๊ถŒํ•œ, CORS, ์ธ์ฝ”๋”ฉ, XSS ์ž‘์—…์‹œ ์ด์šฉ

 

 

dispatcherServlet
์„ค๋ช…

ํ”„๋ŸฐํŠธ ์ปจํŠธ๋กค๋Ÿฌ์™€ ์—ฐ๋™๋˜๋Š” ์ง„์ž…์  ์—ญํ• ์„ ํ•˜๋ฉฐ, ๊ธฐ๋ณธ์ ์ธ ์ฒ˜๋ฆฌ ํ๋ฆ„์„ ์ œ์–ดํ•˜๋Š” ์‚ฌ๋ นํƒ‘ ์—ญํ• ์„ ํ•œ๋‹ค. 

โœฟ ํ”„๋ก ํŠธ ์ปจํŠธ๋กค๋Ÿฌ?
ํด๋ผ์ด์–ธํŠธ ์š”์ฒญ์„ ํ”„๋ŸฐํŠธ ์ปจํŠธ๋กค๋Ÿฌ๋ผ๋Š” ์ปดํฌ๋„ŒํŠธ๊ฐ€ ๋ฐ›์•„ ์š”์ฒญ ๋‚ด์šฉ์— ๋”ฐ๋ผ ์ˆ˜ํ–‰ํ•˜๋Š” ํ•ธ๋“ค๋Ÿฌ(Handler)๋ฅผ ์„ ํƒํ•˜๋Š” ์•„ํ‚คํ…์ฒ˜

 

dispatcherServlet๊ณผ ์—ฐ๋™๋˜๋Š” ์ธํ„ฐํŽ˜์ด์Šค
์ธํ„ฐํŽ˜์ด์Šค๋ช… ์—ญํ• 
HandlerExceptionResolver ์˜ˆ์™ธ์ฒ˜๋ฆฌ ์ธํ„ฐํŽ˜์ด์Šค.
LocaleResolver
LocaleContextResolver
ํด๋ผ์ด์–ธํŠธ Locale ์ •๋ณด๋ฅผ ํ™•์ธํ•˜๊ธฐ ์œ„ํ•œ ์ธํ„ฐํŽ˜์ด์Šค.
ThemeResolver ์Šคํ”„๋ง ํ…Œ๋งˆ๋ฅผ ๊ฒฐ์ •ํ•˜๊ธฐ ์œ„ํ•œ ์ธํ„ฐํŽ˜์ด์Šค.
FlashMapManager FlashMap์ด๋ผ๋Š” ๊ฐ์ฒด๋ฅผ ๊ด€๋ฆฌํ•˜๊ธฐ ์œ„ํ•œ ์ธํ„ฐํŽ˜์ด์Šค.
RequestToViewNameTranslator ํ•ธ๋“ค๋Ÿฌ๊ฐ€ ๋ทฐ ์ด๋ฆ„๊ณผ ๋ทฐ๋ฅผ ๋ฐ˜ํ™˜ํ•˜์ง€ ์•Š๋Š” ๊ฒฝ์šฐ ์ ์šฉ๋˜๋Š” ๋ทฐ ์ด๋ฆ„์„ ํ•ด๊ฒฐํ•˜๊ธฐ ์œ„ํ•œ ์ธํ„ฐํŽ˜์ด์Šค. ์Šคํ”„๋ง MVC์—์„œ ์ œ๊ณตํ•˜๋Š” ๊ธฐ๋ณธ ๊ตฌํ˜„ ํด๋ž˜์Šค๊ฐ€ ์ ์šฉ๋˜์–ด ์žˆ๋‹ค.
HandlerInterceptor ํ•ธ๋“ค๋Ÿฌ ์‹คํ–‰ ์ „ํ›„์— ํ•˜๋Š” ๊ณตํ†ต ์ฒ˜๋ฆฌ๋ฅผ ๊ตฌํ˜„ํ•˜๊ธฐ ์œ„ํ•œ ์ธํ„ฐํŽ˜์ด์Šค. ์ด ์ธํ„ฐํŽ˜์ด์Šค๋Š” ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๊ฐœ๋ฐœ์ž๊ฐ€ ๊ตฌํ˜„ํ•˜๊ณ  ์Šคํ”„๋ง MVC์— ๋“ฑ๋กํ•˜์—ฌ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋‹ค.
MultipartResolver ๋ฉ€ํ‹ฐํŒŒํŠธ ์š”์ฒญ์„ ์ฒ˜๋ฆฌํ•˜๊ธฐ ์œ„ํ•œ ์ธํ„ฐํŽ˜์ด์Šค. ์Šคํ”„๋ง MVC์—์„œ ๋ช‡ ๊ฐ€์ง€ ๊ตฌํ˜„ ํด๋ž˜์Šค๊ฐ€ ์ œ๊ณต๋˜๊ณ  ์žˆ์ง€๋งŒ ๊ธฐ๋ณธ์ ์œผ๋กœ ์ ์šฉ๋˜์ง€ ์•Š๋Š”๋‹ค.

 

 

Handler
์„ค๋ช…

ํ”„๋ ˆ์ž„์›Œํฌ ๊ด€์ ์—์„œ ๋ถˆ๋ฆฌ๋Š” Handler๋Š” ๊ฐœ๋ฐœ์ž๊ฐ€ ์ž‘์„ฑํ•˜๋Š” ํด๋ž˜์Šค์˜ ๊ด€์ ์—์„œ Controller ์ด๋‹ค.

 

 

HandlerMapping
์„ค๋ช…

์š”์ฒญ์— ๋Œ€์‘ํ•  ํ•ธ๋“ค๋Ÿฌ๋ฅผ ์„ ํƒํ•˜๋Š” ์—ญํ• ์„ ์ˆ˜ํ–‰ํ•œ๋‹ค. (์ปจํŠธ๋กค๋Ÿฌ๋‚ด์˜ ๋ฉ”์†Œ๋“œ๊ฐ€ ํ•ธ๋“ค๋Ÿฌ๋กœ ์ธ์‹!)
ํด๋ผ์ด์–ธํŠธ(๋ธŒ๋ผ์šฐ์ €)์—์„œ ์š”์ฒญ์ด ์˜ฌ ๊ฒฝ์šฐ RequestMappingHandlerMapping ํด๋ž˜์Šค๋Š”
์š”์ฒญ ๋‚ด์šฉ(์š”์ฒญ ๊ฒฝ๋กœ ํ˜น์€ HTTP ๋ฉ”์„œ๋“œ)๊ณผ ์š”์ฒญ ๋งคํ•‘ ์ •๋ณด๋ฅผ ๋งค์นญํ•ด์„œ ์‹คํ–‰ํ•  ํ•ธ๋“ค๋Ÿฌ๋ฅด ์„ ํƒํ•œ๋‹ค!

@Controller
class TestController {
    @RequestMapping("/hello")
    public String hello() {
        return "/hi";
    }
    // hello ๋ฉ”์†Œ๋“œ๊ฐ€ ํ•ธ๋“ค๋Ÿฌ!
}

 

 

HandlerAdapter
์„ค๋ช…

ํ•ธ๋“ค๋Ÿฌ ๋ฉ”์„œ๋“œ๋ฅผ ํ˜ธ์ถœํ•˜๋Š” ์—ญํ• ์„ ํ•œ๋‹ค. (RequestMappingHandlerAdapter)
RequestMappingHandlerAdapter ํด๋ž˜์Šค ์—์„œ๋Š” ํ•ธ๋“ค๋Ÿฌ ๋ฉ”์„œ๋“œ์— ๋งค๊ฐœ๋ณ€์ˆ˜๋ฅผ ์ „๋‹ฌํ•˜๊ณ  ๋ฉ”์„œ๋“œ์˜ ์ฒ˜๋ฆฌ ๊ฒฐ๊ณผ๋ฅผ ๋ฐ˜ํ™˜๊ฐ’์œผ๋กœ ๋˜๋Œ๋ ค ๋ณด๋ƒ„
๋นˆ ๊ฐ์ฒด ๊ฒ€์‚ฌ ๋“ฑ๋“ฑ์„ ํ•จ.

 

 

ViewResolver
์„ค๋ช…

ํ•ธ๋“ค๋Ÿฌ์—์„œ ๋ฐ˜ํ™˜ํ•œ ๋ทฐ ์ด๋ฆ„์„ ๋ณด๊ณ , ์ดํ›„์— ์‚ฌ์šฉํ•  View ์ธํ„ฐํŽ˜์ด์Šค์˜ ๊ตฌํ˜„ ํด๋ž˜์Šค๋ฅผ ์„ ํƒํ•˜๋Š” ์—ญํ• ์„ ํ•œ๋‹ค.

 


์ฐธ๊ณ 

(์ฑ…) ์Šคํ”„๋ง ์ฒ ์ € ์ž…๋ฌธ
(์ฑ…) ์Šคํ”„๋ง ๋ถ€ํŠธ๋กœ ๋ฐฐ์šฐ๋Š” ์ž๋ฐ” ์›น ๊ฐœ๋ฐœ
https://exhibitlove.tistory.com/7

 

[springboot] Filter ์„ค์ •

์ถœ์ฒ˜ : https://linked2ev.github.io/gitlog/2019/09/15/springboot-mvc-13-%EC%8A%A4%ED%94%84%EB%A7%81%EB%B6%80%ED%8A%B8-MVC-Filter-%EC%84%A4%EC%A0%95/ Filter๋ž€? ํ•„ํ„ฐ๋ž€? ๊ฑฐ๋ฅธ๋‹ค๋Š” ๋œป์ด๋‹ค. ์„œ๋ธ”๋ฆฟ์˜ Servl..

exhibitlove.tistory.com

https://stargatex.wordpress.com/2015/12/08/spring-mvc-request-lifecycle/

๋ฐ˜์‘ํ˜•

'๊ฐœ๋ฐœ > spring' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

[WebSocket] ์›น์†Œ์ผ“  (0) 2022.03.29
ํŠธ๋žœ์žญ์…˜  (0) 2021.11.25
Spring - DI (Dependency Injection)  (0) 2021.06.01
Spring - AOP(Aspect-Oriented Programming)  (0) 2021.05.25
IOC/DI, DI์‘์šฉ  (0) 2017.11.20

+ Recent posts