[error]
Missing URI template variable for method parameter of type string
재래김유진
2021. 1. 20. 16:29
728x90
반응형
rest api를 만들면서
Missing URI template variable for method parameter of type string
에러가 났다.
@RequestMapping(value="/contents/{contents-mst-seq}")
public ResponseEntity<ContentsVo> contentsDetail(@PathVariable("contentsMstSeq") int contentsMstSeq) {
ContentsVo vo = testService.contentsDetail(contentsMstSeq);
return ResponseEntity.ok(vo);
}
원인 : url로 들어가 있는 {contents-mst-seq}와 @PathVariable에 할당한 변수(contentsMstSeq)가 달라서 발생했다.
해결 : 똑같이 맞춰주니 간단하게 해결됐다.
@RequestMapping(value="/contents/{contents-mst-seq}")
public ResponseEntity<ContentsVo> contentsDetail(@PathVariable("contents-mst-seq") int contentsMstSeq) {
ContentsVo vo = testService.contentsDetail(contentsMstSeq);
return ResponseEntity.ok(vo);
}
728x90
반응형