Skill/spring
[spring boot] controller parameter error : MissingServletRequestParameterException
진열사랑
2021. 2. 15. 13:24
Resolved [org.springframework.web.bind.MissingServletRequestParameterException:Required String parameter 'grpCd' is not present]
@GetMapping("/common/codes/{grpCd}")
public List<TCmCode> common_list( @RequestParam(required = true) String grpCd) throws Exception {
logger.debug("호출되었어요.");
List<TCmCode> list;
logger.debug("grpCd:" + grpCd);
list = codeRepository.findByGrpCd(grpCd);
return list;
}
원인 ) @RequestParam 으로 주려면 ajax 호출시 data : 항목에 넣어야 한다.
주소라인에 값으로 호출하려면 @PathVariable로 받아야 한다.