@Controller 와 @RestController
어노테이션 | 설명 | return 값 |
@Controller | jsp 개발시 사용 | 이동할 jsp 페이지 명 |
@RestController | react / vue 연동 개발시 사용 | json 데이터로 출력됨 |
예시
@RestController
@RequestMapping("/exam06")
public class MultiPathRestController {
@GetMapping("/multi-path/id/{id}/name/{name}")
public Member getMultiPath(
@PathVariable String id,
@PathVariable String name) {
// 맴버 객체 생성
Member member = new Member(id,name);
// 결과 json 데이터로 전송
return member;
}
}
출력
\ 참조 /
Rest Client를 이용해서 Rest API 함수를 테스트 할수 있다
대표적인 툴 : POSTMAN
다만 테스트 툴이 Intelli j 에 내장 되어 있다.
'SpringBoot > code' 카테고리의 다른 글
SpringBoot - ResponseEntity (클래스) (1) | 2023.10.06 |
---|---|
SpringBoot - @RequestBody (0) | 2023.10.06 |
SpringBoot - 웹 cors에 대한 config 파일 (0) | 2023.10.06 |
SpringBoot - @PathVariable (0) | 2023.10.05 |
SpringBoot - @ModelAttribute (0) | 2023.10.05 |