[Practice] 클라이언트 요청에 대한 주소 만들기 (4)
2021. 4. 12. 13:39ㆍSpring/Practice
1. 문제
- Rest 컨트롤러 형식의 어노테이션 이용
- 주소매핑은 Rest 형식의 어노테이션 이용
- HTTP 메서드는 GET 방식
- 리턴값은 "hello rest" 문자열 리턴
- 주소는 "/hello-rest"
2. 풀이
package com.example.jpa.sample;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class SecondController {
// 문제 3
@RequestMapping(value = "/hello-spring", method = RequestMethod.GET)
public String helloSpring() {
return "hello spring";
}
// 문제 4
@GetMapping("/hello-rest")
public String helloRest() {
return "hello rest";
}
}
728x90
'Spring > Practice' 카테고리의 다른 글
[Practice] 공지사항 게시판 목록에 대한 요청 API 만들기 (1) (0) | 2021.04.12 |
---|---|
[Practice] 클라이언트 요청에 대한 주소 만들기 (5) (0) | 2021.04.12 |
[Practice] 클라이언트 요청에 대한 주소 만들기 (3) (0) | 2021.04.12 |
[Practice] 클라이언트 요청에 대한 주소 만들기 (2) (0) | 2021.04.12 |