[Practice] 공지사항 게시판 목록에 대한 요청 API 만들기 (1)

2021. 4. 12. 13:59Spring/Practice

1. 문제

  • REST API 형식으로 구현
  • HTTP METHOD는 GET
  • 요청 주소는 "/api/notice"
  • 리턴값은 문자열 "공지사항입니다." 리턴

 

 

 

2. 풀이

package com.example.jpa.sample.notice;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class ApiNoticeController {

    // 문제 6
    @GetMapping("/api/notice")
    public String noticeString() {
        return "공지사항입니다.";
    }
}

728x90