Web 242

[Spring MVC] @Controller 와 @RestController 차이

https://www.baeldung.com/spring-controller-vs-restcontroller Spring 4.0은 RESTful 웹 서비스 생성을 단순화하기 위해 @RestController 주석을 도입했다. @Controller 와 @ResponseBody를 결합한 편리한 주석으로 컨트롤러 클래스의 모든 요청 처리 메서드에 @ResponseBody 주석을 달 필요가 없다. Spring MVC @Controller simply a specialization of the @Component class, which allows us to auto-detect implementation classes through the classpath scanning. typically use @Contr..

Web/spring 2023.04.01

[Annotation] Spring Scheduling Annotations

https://www.baeldung.com/spring-scheduling-annotations org.springframework.scheduling.annotation 단일 thread 보다 더 복잡한 실행이 필요할 경우에 사용함 @EnableAsync 이 애노테이션은 Spring에서 비동기 기능을 활성화 한다 @Configuration 과 함께 사용해야 한다 *** @Configuration @EnableAsync class VehicleFactoryConfig {} 이렇게 비동기 호출을 활성화 시킨 후 원하는 메서드에 @Async 를 붙여서 정의하면 된다 @EnableScheduling 이 애노테이션을 사용하여 스케쥴링을 활성화 한다 @Configuration 과 함께 사용해야 한다 *** @C..

Web/spring 2023.03.31

[Spring] 요청에 따른 부가응답 추가하기

https://meetup.nhncloud.com/posts/148 Spring에서 요청에 따른 부가 응답 추가하기 (1) : NHN Cloud Meetup Spring에서 요청에 따른 부가 응답 추가하기 (1) meetup.nhncloud.com 해당 출처를 이용하여 코드 작성했습니다. 해당 블로그에서 MicroService 를 베이스로 사용한 부가 처리 작업 예시가 있어서 읽어보았다. OOP 의 특성을 최대한 살려서 코드를 작성했다고 하는데, 정리하자면 Interceptor를 이용하여 부가작업을 처리해주는 코드였다 테스트 코드도 있어서 공부하기에 적합할 것 같아 위의 링크 내용을 참조하여 나에게 맞게 코드를 작성해봤다 기본 API 에 기능을 추가한 것으로 구현 방법은 아래와 같다. 기본 API에 at..

Web/spring 2023.03.29

[Spring Interceptor] Introduction to Spring MVC HandlerInterceptor

https://www.baeldung.com/spring-mvc-handlerinterceptor * spring-web 종속 Spring MVC Handler HandlerMapping은 handler method를 URL에 매핑한다 DispatcherServlet request 처리 시 호출할 수 있다 the DispatcherServlet uses the HandlerAdapter to actually invoke the method. Spring Handler Interceptor a Spring interceptor is a class that either extends the HandlerInterceptorAdapter class or implements the HandlerIntercept..

Web/spring 2023.03.29

[Spring Reading Code] ConstraintViolation

ConstraintViolation 는 Validation을 커스텀하게 사용할 수 있는 interface 이다 initiallize 에서는 ConstraintValidator.super.initialize(constraintAnnotation); valid 할 검증 값들을 가져오고 isValid에서 검증할 내용을 작성한다 true 이면 검증에 통과되었다는 뜻이고 flase이면 에러가 나도록 한다 /** * Defines the logic to validate a given constraint {@code A} * for a given object type {@code T}. * * Implementations must comply to the following restriction: * * {@code ..

Web/ReadingCode 2023.03.28

[Java] Super

https://www.baeldung.com/java-super super class는 부모 class에 액세스한다는 의미이다 The super Keyword With Constructors 부모의 기본 cunstructor를 호출한다 public class SuperSub extends SuperBase { public SuperSub(String message) { super(message); } } 이런 코드가 있다면 child class instance에서 new 키워드로 부모 constructor를 먼저 호출하여 String인수를 전달 하는 SuperSub의 생성자를 호출한다 SuperSub child = new SuperSub("message from the child class"); Acce..

Web/JAVA 2023.03.23
728x90