# Spring - ์„œ๋ธ”๋ฆฟ ์˜ˆ์™ธ ์ฒ˜๋ฆฌ ( Exception )
Study Repository

Spring - ์„œ๋ธ”๋ฆฟ ์˜ˆ์™ธ ์ฒ˜๋ฆฌ ( Exception )

by rlaehddnd0422

์ž๋ฐ”์—์„œ์˜ ์˜ˆ์™ธ

์ž๋ฐ”๋Š” main ๋ฉ”์†Œ๋“œ๋ฅผ ์ง์ ‘ ์‹คํ–‰ํ•  ๋•Œ main ์ด๋ผ๋Š” ์ด๋ฆ„์˜ ์“ฐ๋ ˆ๋“œ๊ฐ€ ์‹คํ–‰๋ฉ๋‹ˆ๋‹ค. ์ด ๋•Œ ์‹คํ–‰ ๋„์ค‘์— try catch๋ฅผ ํ†ตํ•œ ํ•ด๋‹น ์˜ˆ์™ธ ์ฒ˜๋ฆฌ ์กฐ์ฐจ ํ•˜์ง€ ๋ชปํ•˜๊ณ  ์ฒ˜์Œ ์‹คํ–‰ํ•œ main ๋ฉ”์†Œ๋“œ๊นŒ์ง€ ์˜ˆ์™ธ๊ฐ€ ๋„˜์–ด์˜จ ์ดํ›„,  main ๋ฉ”์†Œ๋“œ์—์„œ ์กฐ์ฐจ๋„ ์˜ˆ์™ธ๋ฅผ ์ฒ˜๋ฆฌํ•˜์ง€ ๋ชปํ•˜๋ฉด ์ž๋ฐ”๋Š” ์˜ˆ์™ธ ์ •๋ณด๋ฅผ ๋‚จ๊ธฐ๊ณ  main ์“ฐ๋ ˆ๋“œ๋ฅผ ์ข…๋ฃŒํ•ฉ๋‹ˆ๋‹ค.

 

์›น ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์—์„œ์˜ ์˜ˆ์™ธ

์›น ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์—์„œ๋Š” ์˜ˆ์™ธ๋ฅผ ์–ด๋–ป๊ฒŒ ๋‹ค๋ฃฐ๊นŒ์š”?

์›น ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์€ "์‚ฌ์šฉ์ž ์š”์ฒญ๋ณ„"๋กœ ์“ฐ๋ ˆ๋“œ๊ฐ€ ํ• ๋‹น๋˜๊ณ , ์„œ๋ธ”๋ฆฟ ์ปจํ…Œ์ด๋„ˆ ์•ˆ์—์„œ ์‹คํ–‰๋ฉ๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๋‚ด๋ถ€ ์ปจํŠธ๋กค๋Ÿฌ์—์„œ ์˜ˆ์™ธ๊ฐ€ ๋ฐœ์ƒํ–ˆ์„ ๊ฒฝ์šฐ, ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ try catch๋กœ ์˜ˆ์™ธ๋ฅผ ์žก์•„ ์ฒ˜๋ฆฌํ•˜๋ฉด ๋ฌธ์ œ๊ฐ€ ์—†๊ฒ ์ง€๋งŒ, ์ปจํŠธ๋กค๋Ÿฌ์—์„œ ์˜ˆ์™ธ๋ฅผ ์ฒ˜๋ฆฌํ•˜์ง€ ๋ชปํ•˜๋ฉด ์ด ์ „ ๋‹จ๊ณ„์ธ ์ธํ„ฐ์…‰ํŠธ์—๊ฒŒ ์˜ˆ์™ธ๊ฐ€ ๋„˜๊ฒจ์ง‘๋‹ˆ๋‹ค. ์ธํ„ฐ์…‰ํŠธ์—์„œ๋„ ์˜ˆ์™ธ๋ฅผ ์ฒ˜๋ฆฌํ•˜์ง€ ๋ชปํ•˜๋ฉด ์„œ๋ธ”๋ฆฟ .. ์„œ๋ธ”๋ฆฟ์—์„œ ํ•„ํ„ฐ.. ํ•„ํ„ฐ์—์„œ WAS ๊นŒ์ง€ ์ „ํŒŒ๊ฐ€ ๋ฉ๋‹ˆ๋‹ค.

WAS -> ํ•„ํ„ฐ -> ์„œ๋ธ”๋ฆฟ -> ์ธํ„ฐ์…‰ํ„ฐ -> ์ปจํŠธ๋กค๋Ÿฌ (์˜ˆ์™ธ๋ฐœ์ƒ) 
โ–ถ๏ธŽ WAS(์˜ˆ์™ธ ์ „ํŒŒ๋ฐ›์Œ) <- ํ•„ํ„ฐ <- ์„œ๋ธ”๋ฆฟ <- ์ธํ„ฐ์…‰ํ„ฐ <- ์ปจํŠธ๋กค๋Ÿฌ (์˜ˆ์™ธ์ „ํŒŒ)  

 ๊ฒฐ๊ตญ Tomcat WAS ๊นŒ์ง€ ์˜ˆ์™ธ๊ฐ€ ์ „๋‹ฌ๋˜๊ฒŒ ๋ฉ๋‹ˆ๋‹ค. ๊ทธ๋Ÿผ WAS๋Š” ์˜ˆ์™ธ๋ฅผ ๋ฐ›์œผ๋ฉด ์–ด๋–ป๊ฒŒ ์ฒ˜๋ฆฌํ• ๊นŒ์š”?

 ํ…Œ์ŠคํŠธ๋ฅผ ํ†ตํ•ด ์•Œ์•„๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค.

์ฐธ๊ณ  : ์Šคํ”„๋ง์ด ์•„๋‹Œ ์ˆœ์ˆ˜ ์„œ๋ธ”๋ฆฟ ์ปจํ…Œ์ด๋„ˆ๋Š” ๋‘ ๊ฐ€์ง€ ์˜ˆ์™ธ ์ฒ˜๋ฆฌ๋ฅผ ์ง€์›ํ•ฉ๋‹ˆ๋‹ค. 
1. ์ง์ ‘ ์˜ˆ์™ธ๋ฅผ ๋˜์ง€๋Š” ๋ฐฉ์‹.
2. response.sendError(HTTP ์ƒํƒœ์ฝ”๋“œ, ์˜ค๋ฅ˜ ๋ฉ”์‹œ์ง€) : ์ง์ ‘ ์—๋Ÿฌ๋ฅผ response์— ๋‹ด๋Š” ๋ฐฉ์‹

 

@Controller
public class ServletExController {

    @GetMapping("/error-ex")
    public void errorEx()
    {	
    	// ๋Ÿฐํƒ€์ž„ ์˜ˆ์™ธ๋Š” ์„œ๋ฒ„ ์—๋Ÿฌ -> 500๋ฒˆ๋Œ€
        throw new RuntimeException("์˜ˆ์™ธ ๋ฐœ์ƒ");
    }

http://localhost:8080/error-ex ์š”์ฒญ ์‹œ 

ํ™”์ดํŠธ๋ผ๋ฒจ ์˜ค๋ฅ˜ ํŽ˜์ด์ง€

์ด ์ „์— ์ž์ฃผ ๋ดค๋˜ ํ™”์ดํŠธ๋ผ๋ฒจ ์˜ค๋ฅ˜ ํŽ˜์ด์ง€๊ฐ€ ์ถœ๋ ฅ๋ฉ๋‹ˆ๋‹ค.

 

WAS๋Š” ๊ธฐ๋ณธ์ ์œผ๋กœ ์˜ˆ์™ธ๋ฅผ ๋ฐ›์•˜์„ ๊ฒฝ์šฐ ์Šคํ”„๋ง ๋ถ€ํŠธ๊ฐ€ ์ œ๊ณตํ•˜๋Š” ํ™”์ดํŠธ ๋ผ๋ฒจ ์˜ค๋ฅ˜ ํŽ˜์ด์ง€๋ฅผ ์ถœ๋ ฅํ•˜๊ฒŒ ๋˜๋Š”๋ฐ์š”. ํ™”์ดํŠธ๋ผ๋ฒจ ํŽ˜์ด์ง€๊ฐ€ ์•„๋‹Œ Tomcat์ด ์ œ๊ณตํ•˜๋Š” ์˜ค๋ฅ˜ ํ™”๋ฉด์„ ๋ณผ ์ˆ˜ ์žˆ๋„๋ก ์„ค์ •ํ•˜๋ ค๋ฉด application.properties์— ์•„๋ž˜ ์˜ต์…˜์„ ์ถ”๊ฐ€ํ•ด ์ฃผ์‹œ๋ฉด ๋ฉ๋‹ˆ๋‹ค.

  server.error.whitelabel.enabled=false

Tomcat์ด ์ œ๊ณตํ•˜๋Š” ์˜ค๋ฅ˜ ํ™”๋ฉด

 

ํ†ฐ์บฃ์ด ์ง€์›ํ•˜๋Š” ์˜ค๋ฅ˜ํ™”๋ฉด์ด๋‚˜ ์Šคํ”„๋ง์ด ์ง€์›ํ•˜๋Š” ์˜ค๋ฅ˜ํ™”๋ฉด์ด๋‚˜ ํด๋ผ์ด์–ธํŠธ ์ž…์žฅ์—์„œ ๋ณด์•˜์„ ๋•Œ ๋ชจ๋‘ ์นœํ™”์ ์ด์ง„ ์•Š์•„์š”. 

ํ•˜์ง€๋งŒ ์„œ๋ธ”๋ฆฟ์€ ์˜ค๋ฅ˜ํ™”๋ฉด์„ ์ปค์Šคํ…€ํ•  ์ˆ˜ ์žˆ๋Š” ๊ธฐ๋Šฅ์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.

 

์ปค์Šคํ…€ ๋ฐฉ๋ฒ•

@Component
public class WebServerCustomizer implements WebServerFactoryCustomizer<ConfigurableWebServerFactory> {
    @Override
    public void customize(ConfigurableWebServerFactory factory) {

        ErrorPage errorPage404 = new ErrorPage(HttpStatus.NOT_FOUND, "/error-page/404");
        ErrorPage errorPage500 = new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR,"/error-page/500");
        ErrorPage errorPageEx = new ErrorPage(RuntimeException.class,"/error-page/500");
        factory.addErrorPages(errorPage404,errorPage500,errorPageEx);
    }
}
  1. WebServerFactoryCustomizer<ConfigurableWebServerFactory> ์ธํ„ฐํŽ˜์ด์Šค ์ƒ์† ๋ฐ›์€ ํด๋ž˜์Šค ์ƒ์„ฑ ํ›„ ์ปจํ…Œ์ด๋„ˆ์— ๋“ฑ๋ก
  2. customize() ๋ฉ”์†Œ๋“œ ์˜ค๋ฒ„๋ผ์ด๋”ฉ ํ•ฉ๋‹ˆ๋‹ค.
  3. customize ๋ฉ”์†Œ๋“œ ๋‚ด๋ถ€์— ErrorPage๋ฅผ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค. / ErrorPage(code, path) : code์˜ ์˜ค๋ฅ˜ ๋ฐœ์ƒ ์‹œ path ๊ฒฝ๋กœ๋ฅผ request 
  4. factory์— ์ƒ์„ฑํ•œ ErrorPage๋ฅผ ์ถ”๊ฐ€ํ•ด ์ค๋‹ˆ๋‹ค. / factory.addErrorPage(์ƒ์„ฑํ•œ ErrorPage .. )
@RequestMapping("/error-page/404")
public String errorPage404(HttpServletRequest request, HttpServletResponse response)
{
    log.info("errorPage 404");
    return "error-page/404";
}

์ปจํŠธ๋กค๋Ÿฌ์—์„œ๋Š” ์ปค์Šคํ„ฐ๋งˆ์ด์ €์— ๋“ฑ๋กํ•œ path๋ฅผ ํ†ตํ•ด error-page/404 ๋ทฐ ํ…œํ”Œ๋ฆฟ์œผ๋กœ ์ด๋™ํ•˜๋„๋ก ์„ค์ •ํ–ˆ์Šต๋‹ˆ๋‹ค.

 

error-page/404

์ด๋ ‡๊ฒŒ ๋˜๋ฉด ํ•œ ๋ฒˆ์˜ ์š”์ฒญ์„ ํ†ตํ•ด WAS๋Š” ๋‘ ๋ฒˆ์˜ ์ž‘์—…์„ ํ•˜๊ฒŒ๋ฉ๋‹ˆ๋‹ค. 

1.  WAS("/error-ex"ํ˜ธ์ถœ) -> ํ•„ํ„ฐ -> ์„œ๋ธ”๋ฆฟ -> ์ธํ„ฐ์…‰ํ„ฐ -> ์ปจํŠธ๋กค๋Ÿฌ (์˜ˆ์™ธ๋ฐœ์ƒ) 
2. WAS(์˜ˆ์™ธ ์ „ํŒŒ๋ฐ›์Œ) <- ํ•„ํ„ฐ <- ์„œ๋ธ”๋ฆฟ <- ์ธํ„ฐ์…‰ํ„ฐ <- ์ปจํŠธ๋กค๋Ÿฌ (์˜ˆ์™ธ์ „ํŒŒ)  
3. โ–ถ๏ธŽ WAS( WebServerCustomizer๋ฅผ ํ†ตํ•ด ์˜ˆ์™ธ์™€ ๋งคํ•‘๋œ URI๋ฅผ ํ†ตํ•ด ์–ด๋Œ‘ํ„ฐ(@RequestMapping("/error-page/500") ํ˜ธ์ถœ) -> ํ•„ํ„ฐ -> ์„œ๋ธ”๋ฆฟ -> ์ธํ„ฐ์…‰ํ„ฐ -> ์–ด๋Œ‘ํ„ฐ์™€ ๋งคํ•‘๋œ ์ปจํŠธ๋กค๋Ÿฌ(errorPage404) ํ˜ธ์ถœ -> ๋ทฐ ํ…œํ”Œ๋ฆฟ ๋ฆฌํ„ด 

 

โ—๏ธ๋‹น์—ฐํ•œ ์ด์•ผ๊ธฐ์ง€๋งŒ ํด๋ผ์ด์–ธํŠธ๋Š” ์„œ๋ฒ„ ๋‚ด๋ถ€์—์„œ ์ด๋ ‡๊ฒŒ ๋‘ ๋ฒˆ ๋™์ž‘ํ•˜๋Š”์ง€ ์•Œ ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค. ( WAS ์„ ์—์„œ ์ฒ˜๋ฆฌํ•˜๊ณ  ์ตœ์ข… ๊ฒฐ๊ณผ์ธ ๋ทฐ๋งŒ ํด๋ผ์ด์–ธํŠธ์—๊ฒŒ ๋ฆฌํ„ดํ•˜๊ธฐ ๋•Œ๋ฌธ์— )

 

โ—๏ธ์ด ๋•Œ ์ค‘์š”ํ•œ ์ ์€ 3๋ฒˆ ์žฌํ˜ธ์ถœ ๊ณผ์ •์—์„œ request์˜ attribute์— ์˜ค๋ฅ˜ ์ •๋ณด๋ฅผ ์ถ”๊ฐ€ํ•ด์„œ ๋„˜๊ฒจ์ค€๋‹ค๋Š” ์ .

์˜ค๋ฅ˜ ์ •๋ณด๋Š” RequestDispatcher์— ์ƒ์ˆ˜๋กœ ์ •์˜๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค.

  • javax.servlet.error.exception : ์˜ˆ์™ธ
  • javax.servlet.error.exception_type : ์˜ˆ์™ธ ํƒ€์ž…
  • javax.servlet.error.message : ์˜ค๋ฅ˜ ๋ฉ”์‹œ์ง€
  • javax.servlet.error.request_uri : ํด๋ผ์ด์–ธํŠธ ์š”์ฒญ URI
  • javax.servlet.error.servlet_name : ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•œ ์„œ๋ธ”๋ฆฟ ์ด๋ฆ„
  • javax.servlet.error.status_code : HTTP ์ƒํƒœ ์ฝ”๋“œ
@RequestMapping("/error-page/500")
public String errorPage500(HttpServletRequest request, HttpServletResponse response) {

    log.info("errorPage 500");
    printErrorInfo(request);
    return "error-page/500";
}

private void printErrorInfo(HttpServletRequest request)
{
    log.info("ERROR_EXCEPTION: ex=" ,request.getAttribute(ERROR_EXCEPTION));
    log.info("ERROR_EXCEPTION_TYPE: {}",request.getAttribute(ERROR_EXCEPTION_TYPE));
    log.info("ERROR_MESSAGE: {}", request.getAttribute(ERROR_MESSAGE)); // ex์˜ ๊ฒฝ์šฐ NestedServletException ์Šคํ”„๋ง์ด ํ•œ๋ฒˆ ๊ฐ์‹ธ์„œ ๋ฐ˜ํ™˜
    log.info("ERROR_REQUEST_URI: {}",request.getAttribute(ERROR_REQUEST_URI));
    log.info("ERROR_SERVLET_NAME: {}",request.getAttribute(ERROR_SERVLET_NAME));
    log.info("ERROR_STATUS_CODE: {}",request.getAttribute(ERROR_STATUS_CODE));
    log.info("dispatchType={}", request.getDispatcherType());
}

๋‘ ๋ฒˆ์งธ ์š”์ฒญ์— request์— ๋‹ด๊ธด ERROR ์ •๋ณด ์ถœ๋ ฅ

 

์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•˜๋ฉด ์˜ค๋ฅ˜ํŽ˜์ด์ง€๋ฅผ ์ถœ๋ ฅํ•˜๊ธฐ ์œ„ํ•ด WAS ๋‚ด๋ถ€์—์„œ ํ˜ธ์ถœ์ด ์ถ”๊ฐ€์ ์œผ๋กœ ํ•œ๋ฒˆ ๋” ์ผ์–ด๋‚ฉ๋‹ˆ๋‹ค. 

๊ทธ๋ ‡๋‹ค๋ฉด ํ•„ํ„ฐ์™€, ์„œ๋ธ”๋ฆฟ, ์ธํ„ฐ์…‰ํ„ฐ, ์ปจํŠธ๋กค๋Ÿฌ๊ฐ€ ์ด ๋‘ ๋ฒˆ ํ˜ธ์ถœ๋˜๋Š”๊ฑด๋ฐ, ์„œ๋ธ”๋ฆฟ๊ณผ ์ปจํŠธ๋กค๋Ÿฌ๋Š” ํ•„์ˆ˜์ ์œผ๋กœ ํ˜ธ์ถœํ•ด์•ผ ๋˜๊ธฐ ๋•Œ๋ฌธ์— ๊ทธ๋ ‡๋‹ค ์น˜๋Š”๋ฐ, ํ•„ํ„ฐ๋ž‘ ์ธํ„ฐ์…‰ํ„ฐ๋Š” ๊ตณ์ด ์•„๋ž˜์ฒ˜๋Ÿผ ๋‘ ๋ฒˆ ํ˜ธ์ถœํ•  ์ด์œ ๊ฐ€ ์—†๊ฒ ์ฃ ? ์„ค์ •์„ ํ†ตํ•ด ์ค‘๋ณต ํ˜ธ์ถœ์„ ๋นผ๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.

์„œ๋ธ”๋ฆฟ ์˜ˆ์™ธ ์ฒ˜๋ฆฌ - ํ•„ํ„ฐ ์ค‘๋ณต ํ˜ธ์ถœ ์ œ๊ฑฐ 

์ž๋ฐ” ํ‘œ์ค€ ์ŠคํŽ™์ด ์ง€์›ํ•˜๋Š” ํ•„ํ„ฐ์˜ ๊ฒฝ์šฐ์—๋Š” ๋“ฑ๋กํ•  ๋•Œ dispatcherTypes ์˜ต์…˜์„ ํ†ตํ•ด ํ•„ํ„ฐ๋ฅผ ์ ์šฉํ•  distpatcherType์„ ์„ค์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Bean
    public FilterRegistrationBean logFilter()
    {
        FilterRegistrationBean<Filter> filterRegistrationBean = new FilterRegistrationBean<>();
        filterRegistrationBean.setFilter(new LogFilter());
        filterRegistrationBean.setOrder(1);
        filterRegistrationBean.addUrlPatterns("/*");
        filterRegistrationBean.setDispatcherTypes(DispatcherType.REQUEST,DispatcherType.ERROR);
        return filterRegistrationBean;
    }

default๋กœ REQUEST๋งŒ ์„ค์ •๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค๋งŒ, setDistPatcherTypes๋ฅผ ํ†ตํ•ด ์ง์ ‘ ๋“ฑ๋กํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

ERRORS๋ฅผ ๋นผ๊ณ  ์‹คํ–‰ํ•˜๋ฉด request์— ์˜ค๋ฅ˜์ •๋ณด๊ฐ€ ๋‹ด๊ฒจ์žˆ๋Š”๊ฒฝ์šฐ ํ•„ํ„ฐ๋ฅผ ์ ์šฉํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.

DispatcherType 

REQUEST : ํด๋ผ์ด์–ธํŠธ ์š”์ฒญ

ERROR : ์˜ค๋ฅ˜ ์š”์ฒญ

FORWARD : MVC์—์„œ ๋ฐฐ์› ๋˜ ์„œ๋ธ”๋ฆฟ์—์„œ ๋‹ค๋ฅธ ์„œ๋ธ”๋ฆฟ์ด๋‚˜ JSP๋ฅผ ํ˜ธ์ถœํ•  ๋•Œ

  • RequestDispatcher.forward(request, response);

INCLUDE : ์„œ๋ธ”๋ฆฟ์—์„œ ๋‹ค๋ฅธ ์„œ๋ธ”๋ฆฟ์ด๋‚˜ JSP์˜ ๊ฒฐ๊ณผ๋ฅผ ํฌํ•จํ•  ๋•Œ

  • RequestDispatcher.include(request, response);

ASYNC : ์„œ๋ธ”๋ฆฟ ๋น„๋™๊ธฐ ํ˜ธ์ถœ

 

์„œ๋ธ”๋ฆฟ ์˜ˆ์™ธ ์ฒ˜๋ฆฌ - ์ธํ„ฐ์…‰ํ„ฐ ์ค‘๋ณต ํ˜ธ์ถœ ์ œ๊ฑฐ

์ž๋ฐ”๊ฐ€ ์•„๋‹Œ ์Šคํ”„๋ง ๊ธฐ์ˆ ์ธ ์ธํ„ฐ์…‰ํ„ฐ์˜ ๊ฒฝ์šฐ์—๋Š” ํ›จ์”ฌ ๊ฐ„๋‹จํ•˜๊ฒŒ ํ•ด๊ฒฐํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

๊ทธ๋ƒฅ ์˜ค๋ฅ˜ ํŽ˜์ด์ง€ ๊ฒฝ๋กœ๋ฅผ excluePathPatterns๋ฅผ ์‚ฌ์šฉํ•ด์„œ ๋นผ์ฃผ๋ฉด ๋ฉ๋‹ˆ๋‹ค.

@Configuration
public class WebConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LogInterceptor())
                .order(1)
                .addPathPatterns("/**")
                .excludePathPatterns("/css/**","/*.ico","/error","/error-page/**");
    }
}

 

์„œ๋ธ”๋ฆฟ์—์„œ ์˜ˆ์™ธ ํ๋ฆ„์„ ์•Œ์•„๋ณด๊ณ  ํ•„ํ„ฐ์˜ setDispatcherTypes์™€ ์ธํ„ฐ์…‰ํ„ฐ์˜ excludePatterns ์˜ต์…˜์œผ๋กœ ์‚ฌ์šฉํ•ด ERROR๊ฐ€ ์•„๋‹Œ REQUEST์— ๋Œ€ํ•ด์„œ๋งŒ ๋กœ๊ทธ๋ฅผ ์ถœ๋ ฅํ•ด ๋ณด์•˜์Šต๋‹ˆ๋‹ค. 

์ด๊ฑธ ์ž˜ ํ™œ์šฉํ•œ๋‹ค๋ฉด ํ•œ๋‹ค๋ฉด ํ•„ํ„ฐ์™€ ์ธํ„ฐ์…‰ํ„ฐ์˜ ์ค‘๋ณตํ˜ธ์ถœ์„ ๋ง‰์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค!

์˜ˆ๋ฅผ ๋“ค์–ด ๋กœ๊ทธ์ธ ์ธ์ฆ ์ฒดํฌ ๊ฐ™์€ ๊ฒฝ์šฐ ์ด๋ฏธ ํ•œ๋ฒˆ ํ•„ํ„ฐ๋‚˜, ์ธํ„ฐ์…‰ํ„ฐ์—์„œ ๋กœ๊ทธ์ธ ์ฒดํฌ๋ฅผ ์™„๋ฃŒํ–ˆ๋Š”๋ฐ ์„œ๋ฒ„ ๋‚ด๋ถ€์—์„œ ์˜ค๋ฅ˜ ํŽ˜์ด์ง€๋ฅผ ํ˜ธ์ถœํ–ˆ์„ ๋•Œ, ํ•ด๋‹น ํ•„ํ„ฐ๋‚˜ ์ธํ„ฐ์…‰ํŠธ๊ฐ€ ํ•œ๋ฒˆ ๋” ํ˜ธ์ถœ๋˜๋Š” ๊ฒƒ์„ ํ•„ํ„ฐ์˜ setDispatcherTypes๋‚˜ ์ธํ„ฐ์…‰ํ„ฐ์˜ excludePathPatterns๋ฅผ ์ด์šฉํ•ด ๋ง‰์„ ์ˆ˜ ์žˆ๊ฒ ์Šต๋‹ˆ๋‹ค.

 

<์ฐธ๊ณ ์ž๋ฃŒ>

https://www.inflearn.com/course/%EC%8A%A4%ED%94%84%EB%A7%81-mvc-2/dashboard

 

์Šคํ”„๋ง MVC 2ํŽธ - ๋ฐฑ์—”๋“œ ์›น ๊ฐœ๋ฐœ ํ™œ์šฉ ๊ธฐ์ˆ  - ์ธํ”„๋Ÿฐ | ๊ฐ•์˜

์›น ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๊ฐœ๋ฐœ์— ํ•„์š”ํ•œ ๋ชจ๋“  ์›น ๊ธฐ์ˆ ์„ ๊ธฐ์ดˆ๋ถ€ํ„ฐ ์ดํ•ดํ•˜๊ณ , ์™„์„ฑํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. MVC 2ํŽธ์—์„œ๋Š” MVC 1ํŽธ์˜ ํ•ต์‹ฌ ์›๋ฆฌ์™€ ๊ตฌ์กฐ ์œ„์— ์‹ค๋ฌด ์›น ๊ฐœ๋ฐœ์— ํ•„์š”ํ•œ ๋ชจ๋“  ํ™œ์šฉ ๊ธฐ์ˆ ๋“ค์„ ํ•™์Šตํ•  ์ˆ˜ ์žˆ

www.inflearn.com

 

๋ธ”๋กœ๊ทธ์˜ ์ •๋ณด

Study Repository

rlaehddnd0422

ํ™œ๋™ํ•˜๊ธฐ