[Error] Spring Boot - 공통 템플릿 적용 시 발생한 오류 해결

dwkim·2023년 4월 2일
0

<점프 투 스프링부트> 복습하면서 공통 템플릿을 만들다가 발생한 오류
https://wikidocs.net/161911

아무리 봐도 코드에는 오류가 없는데 왜 question_form에서 문제가 생기지?? 싶었다..





Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.

Sun Apr 02 23:05:22 KST 2023
There was an unexpected error (type=Internal Server Error, status=500).
An error happened during template parsing (template: "URL [file:src/main/resources/templates/question_form.html]")
org.thymeleaf.exceptions.TemplateInputException: An error happened during template parsing (template: "URL [file:src/main/resources/templates/question_form.html]") // 템플릿 엔진이 question_form 이라는 html파일을 읽을 때 문제가 발생했다
at org.thymeleaf.templateparser.markup.AbstractMarkupTemplateParser.parse(AbstractMarkupTemplateParser.java:241)
at org.thymeleaf.templateparser.markup.AbstractMarkupTemplateParser.parseStandalone(AbstractMarkupTemplateParser.java:100)
at

(중략)
java.base/java.lang.Thread.run(Thread.java:833)
Caused by: org.attoparser.ParseException: Error resolving template [form_errors], template might not exist or might not be accessible by any of the configured Template Resolvers (template: "questionform" - line 5, col 10)
at org.attoparser.MarkupParser.parseDocument(MarkupParser.java:393)
at org.attoparser.MarkupParser.parse(MarkupParser.java:257)
at org.thymeleaf.templateparser.markup.AbstractMarkupTemplateParser.parse(AbstractMarkupTemplateParser.java:230)
... 48 more
Caused by: org.thymeleaf.exceptions.TemplateInputException: Error resolving template [form_errors], template might not exist or might not be accessible by any of the configured Template Resolvers (template: "question_form" - line 5, col 10)_ // question_form 이라는 파일의 5번째 줄에있는 코드가 문제라서, 이 파일에 접근이 불가능하거나 존재하지 않는 파일이다

<html layout:decorate="~{layout}">
<div layout:fragment="content" class="container">
  <h5 class="my-3 border-bottom pb-2">질문등록</h5>
  <form th:action="@{/question/create}" th:object="${questionForm}" method="post">
    <div th:replace="~{form_errors :: formErrorsFragment}"></div>    

question_form 중에서 마지막 코드가 문제라는 소리.

근데 코드는 또 문제가 없다.
같은 디렉토리 내부의 공통 템플릿인 form_errors 파일에서 formErrorsFragment 라는 프래그먼트를 불러오겠다는 것이다!

지우고 다시 쓰기를 반복했는데도 도저히 모르겠어서 멘토님께 질문을 했는데

허무하게도 form_errors파일명을 잘못 썼었다;;;;;
from이 아니라 form...

앞으로 파일명도 잘 체크해야겠다!

profile
예비 백엔드 개발자

0개의 댓글