@RequestMapping
- client의 요청이 왔을 때, 해당 url에 해당하는 Controller, Method 를 호출합니다.
- Controller 와 Method 에 Annotation 을 모두 적용하면, 적용된 값을 조합하여 매핑될 경로를 설정합니다.
@RequestMapping("/api")
public class Controller {
@RequestMapping({"/Password", "/Password/v1"})
public ApiResponse password(){
return ApiResponse.OK;
}
}
@RequestMapping(value="/api") == @RequestMapping("/api")
@RequestMapping(method = {RequestMethod.GET, RequestMethod.POST})
- 경로변수 사용
@PathVariable("myPath")
@RequestMapping({"/{myid}"})
public ApiResponse id(@PathVariable("myid") String id)
log.debug("myid = {}", id)
return ApiResponse.OK;
}
@PostMapping
- Post 로 Mapping 을 하는 방법입니다.
@RequestMapping
을 간단하게 줄여쓸 수 있습니다.
@PostMapping("/api")
public ApiResponse password(){
return ApiResponse.OK;
}
@GetMapping
- Get 로 Mapping 을 하는 방법입니다.
@RequestMapping
을 간단하게 줄여쓸 수 있습니다.
@GetMapping("/api")
public ApiResponse password(){
return ApiResponse.OK;
}