Thymeleaf 에러
에러 내용
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;
}
발생 원인
- java 객체로 return 받도록 해놓은 코드에
@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;
}
Author And Source
이 문제에 관하여(Thymeleaf 에러), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://velog.io/@zzee22su/Thymeleaf-에러저자 귀속: 원작자 정보가 원작자 URL에 포함되어 있으며 저작권은 원작자 소유입니다.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)