IT/Spring Boot

IT/Spring Boot

[paging] 페이징 처리 구현하기 (spring boot, mybatis, react-pagination)

1. Spring Boot에서 mybatis와 페이징 처리하기 mybatis를 사용하여 데이터베이스와 연동하고, 페이징 처리를 할 수 있습니다. mybatis에서는 RowBouds 클래스를 사용하여 페이징 처리를 합니다. 예를들어, 다음과 같이 UserMapper 인터페이스를 작성할 수 있습니다. import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; import org.apache.ibatis.session.RowBounds; import java.util.List; @Mapper public interface UserMapper { List findAll(@Param("offset") int off..

IT/Spring Boot

[Exception] 스프링 전역 예외 처리 방법 - (RestControllerAdvice, ExceptionHandler)

@ControllerAdvice @RestControllerAdvice 프로젝트내 모든 Exception이 발생하면 거쳐간다. @ExceptionHandler 컨트롤러에 어떠한 요청이 있을때 모든 예외를 Catch 하여 처리를 해주는 기능이다. 전역으로 사용할 Exception Class 생성 - @RestControllerAdvice @Advice 어노테이션이 붙은 클래스는, Exception이 나는 모든경우에 거쳐간다. import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.ExceptionHandler; im..

org.woodies.dev
'IT/Spring Boot' 카테고리의 글 목록