[Practice] 클라이언트 요청에 대한 주소 만들기 (3)
2021. 4. 12. 13:36ㆍSpring/Practice
1. 문제
- 컨트롤러 인식을 위한 Controller 어노테이션 이용
- 주소매핑은 RequestMapping이 아닌 Rest 형식의 어노테이션 이용
- HTTP 메서드는 GET 방식 (어노테이션 이용)
- 리턴값은 "hello spring" 문자열 리턴 (문자열 리턴을 위한 어노테이션 이용)
- 주소는 "/hello-spring"
2. 풀이
package com.example.jpa.sample;
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";
}
}
728x90
'Spring > Practice' 카테고리의 다른 글
[Practice] 클라이언트 요청에 대한 주소 만들기 (5) (0) | 2021.04.12 |
---|---|
[Practice] 클라이언트 요청에 대한 주소 만들기 (4) (0) | 2021.04.12 |
[Practice] 클라이언트 요청에 대한 주소 만들기 (2) (0) | 2021.04.12 |
[Practice] 클라이언트 요청에 대한 주소 만들기 (1) (0) | 2021.04.12 |