Spring #7

ims·2020년 11월 5일
0

BlueDot-Spring

목록 보기
8/13

생성자 주입 > 필드주입

필드주입 = @Autowired

@Autowired -> private final & construtor

https://madplay.github.io/post/why-constructor-injection-is-better-than-field-injection

  • 필드 주입(Field Injection) = 먼저 빈을 생성한 후에 필드에 대해서 주입한다.

  • 생성자 주입(Constructor Injection) = 즉, 먼저 빈을 생성하지 않는다.

요약해보자면

  1. 순환참조 방지
  2. 테스트 코드 작성 쉽게 가능 ( @Mock등 annotation을 달아주지 않아도 된다 )
  3. final 로 선언하므로 실행 중에 객체가 변하는 것을 막을 수 있다.

RequestParams / PathVariable

PathVariable

  • localhost:8080/13/24

URL 경로로 값을 전달

RequestParams

  • localhost:8080?age=3&name=ersu

URL parameter로 값을 전달

https://willbesoon.tistory.com/102

MultipartForm data 받기

1.@RequestParam 이용 2. Servlet 어쩌구 이용 3. Class 이용

https://caileb.tistory.com/152

3번이 안먹는다. 일단 1번으로..

profile
티스토리로 이사했습니다! https://imsfromseoul.tistory.com/ + https://camel-man-ims.tistory.com/

0개의 댓글