• Home
  • About
    • lahuman photo

      lahuman

      열심히 사는 아저씨

    • Learn More
    • Facebook
    • LinkedIn
    • Github
  • Posts
    • All Posts
    • All Tags
  • Projects

Spring MVC Controller 에서 @PathVariable에 name을 빼먹으면 오류가 났다.

27 Dec 2017

Reading time ~1 minute

이전에 사용하던 방식으로 처리 했는데 URI 템플릿 변수가 누락 되었다는 오류 발생

3개월 전만에도 문제 없었던 Spring MVC 코드 인데 무엇을 잘못한 것인지 오류가 났다.

  • 코드
  @RequestMapping(value = "/{id}", method = RequestMethod.GET)
    public DknetInfoResDTO view(@NonNull @PathVariable Long seq){
        DknetInfo dknetInfo = dknetService.getDknetInfo(seq);
        return modelMapper.map(dknetInfo, DknetInfoResDTO.class);
    }
  • 오류 내용
Whitelabel Error Page

This application has no explicit mapping for /error, so you are seeing this as a fallback.
Wed Dec 27 13:28:56 KST 2017
There was an unexpected error (type=Internal Server Error, status=500).
Missing URI template variable 'seq' for method parameter of type Long

원인은 PathVariable에 id 와 파라메터에 변수 값 seq를 혼합해서 사용하였기 때문이다.

쉬운데 놓치는 일이 너무 많다.

영어만 잘해도 반은 먹고 갈텐데…



단상 Share Tweet +1