목록Back-end (69)
개발자 키우기
보호되어 있는 글입니다.
보호되어 있는 글입니다.
보호되어 있는 글입니다.
보호되어 있는 글입니다.
스프링 프레임워크에서 HTTP 요청과 응답의 본문(body)을 변환하는 역할을 수행하는 인터페이스입니다. HTTP 요청 본문을 메서드의 파라미터 타입으로 변환하거나, HTTP 응답 본문을 특정 타입으로 변환하는 등 다양한 작업을 수행할 수 있습니다. package org.springframework.http.converter; import java.io.IOException; import java.util.Collections; import java.util.List; import org.springframework.http.HttpInputMessage; import org.springframework.http.HttpOutputMessage; import org.springframework.http...
@ExceptionHandler 특정 예외 타입에 대한 처리 메서드를 지정하는 데 사용됩니다. 해당 예외가 발생하면 이 메서드가 호출되어 예외를 처리하고 클라이언트에게 응답을 전달합니다. 아래 코드에서 /exception 으로 get 요청을 하면 IllegalStateException이 발생하게 된다. 하지만 해당 컨트롤에 @ExceptionHandler 이 달려있는 메서드에서 IllegalStateException이 발생하는 걸 처리한다. @GetMapping("/exception") public String exception() { throw new IllegalStateException("Sorry!"); } @ExceptionHandler public String handle(IllegalStat..
@RequestParam HTTP 요청의 파라미터 값을 메서드의 매개변수에 바인딩하는 데 사용됩니다. 주로 URL 쿼리 문자열이나 POST 요청의 폼 데이터에서 파라미터 값을 추출할 때 사용합니다. HTTP 파라미터 이름이 변수 이름과 같으면 (name="xx") 생략 가능 String , int , Integer 등의 단순 타입이면 @RequestParam 생략 가능 @RequestParam(required = true) String username 으로 username이 없으면 400에러가 뜬다 defaultValue를 설정할 수도 있음 @PathVariable URI의 일부를 변수로 추출하여 메서드의 매개변수에 바인딩하는 데 사용됩니다. 주로 RESTful 웹 애플리케이션에서 경로 변수를 추출할 때..
PropertyEditor는 스프링이 기본적으로 제공하는 바인딩용 타입 변환 API다. 아래는 propertyEditor가 지원하는 타입들이다. ( 스프링 5.3.23 기준 ) org.springframework.beans.propertyeditors ByteArrayPropertyEditor CharacterEditor CharArrayPropertyEditor CharsetEditor ClassArrayEditor ClassEditor CurrencyEditor CustomBooleanEditor CustomCollectionEditor CustomDateEditor CustomMapEditor CustomNumberEditor FileEditor InputSourceEditor InputStream..