[RESTful Web Service]-2

EarlyBird·2021년 10월 31일
0

RESTful Web Service

목록 보기
2/6
post-thumbnail

Dowon Lee님의 Spring Boot를 이용한 RESTful Web Services 개발 강의를 학습한 내용입니다.

Maven 기반

포트 변경

application.yml

server:
  port: 8088

yml 장점

  • 모든 데이터를 리스트, 해쉬, 스칼라 데이터의 조합으로 표현 가능
  • 가독성이 좋다.

ㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡㅡ

  • @RestController : @Controller + @ResponseBody, View를 갖지 않는 REST Data(JSON/XML) 반환
  • @Data(lombok) : Getter, Setter, toString, 생성자 등
  • @AllArgsConstructor : 모든 Argument를 가진 생성자 생성
  • @NoArgsConstructor : 디폴트 생성자 생성

DispatcherServlet

  • 클라이언트의 모든 요청을 한 곳으로 받아 처리

Path Variable

    @GetMapping(path = "/hello-world-bean/path-variable/{name}")
    public HelloWorldBean helloWorldBean(@PathVariable String name){
        return new HelloWorldBean(String.format("Hello World, %s",  name));
    }
  • @PathVariable : URI 가변 데이터
  • {name}과 @PathVariable의 name은 동일해야한다.
profile
안되면 되게 합시다

0개의 댓글