본문 바로가기
카테고리 없음

[스터디] 스프링 부트 개념과 활용 - 6주차 ( ~ 4/03)

by shakevan 2022. 4. 3.

스프링 웹 MVC 정적 리소스 지원

https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#web.servlet.spring-mvc.static-content

 

Spring Boot Reference Documentation

This section goes into more detail about how you should use Spring Boot. It covers topics such as build systems, auto-configuration, and how to run your applications. We also cover some Spring Boot best practices. Although there is nothing particularly spe

docs.spring.io

default 리소스 경로

- /static

- /public

- /resources

- /META_INF/resources

 

정적 리소스 경로를 추가하는법

WebMvcConfigurer를 상속받아 addResourceHandlers를 추가해줌

 

 

Web Jar

- 의존성을 jar로 추가하는거

 

 

Welcome Page

https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#web.servlet.spring-mvc.welcome-page

 

Spring Boot Reference Documentation

This section goes into more detail about how you should use Spring Boot. It covers topics such as build systems, auto-configuration, and how to run your applications. We also cover some Spring Boot best practices. Although there is nothing particularly spe

docs.spring.io

기본은 index.html

 

favicon

탭에 보여지는 아이콘

 

ExceptionHandler

https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#web.servlet.spring-mvc.error-handling

 

Spring Boot Reference Documentation

This section goes into more detail about how you should use Spring Boot. It covers topics such as build systems, auto-configuration, and how to run your applications. We also cover some Spring Boot best practices. Although there is nothing particularly spe

docs.spring.io

 

기본 에러 핸들링은 BasicErrorController에 있다.

 

커스텀 에러 핸들러 만들기(@ExceptionHandler)

 

커스텀 에러 페이지

{status code}.html을 만들면 어떤 에러의 핸들링도 하지 않으면 해당 페이지를 노출시켜줌

 

Spring HATEOAS

https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#web.spring-hateoas

 

Spring Boot Reference Documentation

This section goes into more detail about how you should use Spring Boot. It covers topics such as build systems, auto-configuration, and how to run your applications. We also cover some Spring Boot best practices. Although there is nothing particularly spe

docs.spring.io

- 리소스와 연관된 정보의 링크를 함께 제공

- ObjectMaaper, LinkDiscovers 제공(ObjectMapper는 web의존성만 추가해줘도 됨)

 

CORS(Cross-Origin Resource Sharing)

- SOP(Single-Origin Policy) vs SORS ?

- Origin는 아래 3가지의 조합

    - URI 스키마 (http, https)

    - hostname (naver.com)

    - 포트

스프링 MVC에서 CORS를 지원

https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#web.servlet.spring-mvc.cors

 

Spring Boot Reference Documentation

This section goes into more detail about how you should use Spring Boot. It covers topics such as build systems, auto-configuration, and how to run your applications. We also cover some Spring Boot best practices. Although there is nothing particularly spe

docs.spring.io

 

댓글