에러 내용
Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.thymeleaf.exceptions.TemplateInputException: Error resolving template [hello-api], template might not exist or might not be accessible by any of the configured Template Resolvers] with root cause
에러 발생 위치
@GetMapping("hello-api")
public Hello helloApi(@RequestParam("name") String name) {
Hello hello = new Hello();
hello.setName(name);
return hello;
}
발생 원인
@ResponseBody
를 사용하지 않아 위와 같은 에러 발생.@ResponseBody
@ResponseBody를 사용하면 http 요청 body를 자바객체로 전달받을 수 있다.
개선 방법
ResponseBody 어노테이션을 추가하여 body를 자바 객체로 받을 수 있도록 하였음.
@GetMapping("hello-api")
@ResponseBody
public Hello helloApi(@RequestParam("name") String name) {
Hello hello = new Hello();
hello.setName(name);
return hello;
}