Notice
Recent Posts
Recent Comments
Link
«   2024/10   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
Archives
Today
Total
관리 메뉴

한바다

서블릿 실행 오류 ERROR[templates/index.html]") 본문

servlet

서블릿 실행 오류 ERROR[templates/index.html]")

한바다진화 2024. 6. 13. 13:18

서블릿 실행 오류

✅ 데모 프로젝트 실행시 아래와 같은 오류가 떳다!

Exception processing template "index": An error happened during template parsing (template: "class path resource [templates/index.html]")

 

브라우저에 로컬코드 입력후 실행시키니 아래와 같이 에러 화면이 노출되었다.

[에러코드]

2024-06-13T12:48:40.379+09:00 ERROR 6696 --- [demoProject2] [nio-8081-exec-1] org.thymeleaf.TemplateEngine

 : [THYMELEAF][http-nio-8081-exec-1]

Exception processing template "index": An error happened during template parsing (template: "class path resource [templates/index.html]")

 

org.thymeleaf.exceptions.TemplateInputException: An error happened during template parsing (template: "class path resource [templates/index.html]")

 

위 에러코드 파악시 index.html 페이지에서 아래와 같은 사유로 에러가 발생하였다!!

1.태그를 하나 더 씀

<li><a href="/example/ex3">타임리프 예제3</a></li>

</li>

 

[수정]

<li><a href="/example/ex3">타임리프 예제3</a></li>

 

 

2.동일한 html코드문을 <pre>태그에 써서 충돌을 방지하고자 뛰어쓰기를 해야 하는데 하지 않았다.

<html xmlns:th="http://www.thymeleaf.org">

 [수정]

 

3. html태그에 주소 오타가 났다.

[오타 코드]

<html xmlns:th=http://www.thymeleaf.org">

[수정코드]

<html xmlns:th="http://www.thymeleaf.org">

 

4.태그 내에 쌍따옴표 누락

[오타코드]

<a href="#>찾아오시는 길</a>

[수정코드]

a href="#">찾아오시는 길</a>

 

위 4가지 오류 사항을 수정후 브라우저 로컬주소에서 실행시키니

아래와 같이 깔끔하게 실행되었다.

[깔끔하게 실행된 화면]

 

  두번째!!!아래와 같은 오류가 발생 하였다.

Error resolving template [member/memberInfo], template might not exist or might not be accessible by any of the configured Template Resolvers
org.thymeleaf.exceptions.TemplateInputException: Error resolving template [member/memberInfo], template might not exist or might not be accessible by any of the configured Template Resolvers

▶ 확인 시, 탬플릿을 해결하는 도중 오류가 발생하였다  탬플릿이 존재하지 않나 memberInfo org.thymeleaf.exceptions 액세스하지 않았을수 있습니다. 하여 ' memberInfo' 파일을 확인 하였다.

 

정답지 깃을 보고도 눈을 씻고 찾아도 오타가 보이지 않을때 쌤이 아래와 같은 방법을 알려주셨다!!

서블릿 이클립스에서 오타쟁이 html을 ctrl+c한다음 ctrl+v 해준다. 그리고 ctrl+v 해준 이름_git비교로 변경해준후

정답지를 붙인다.

그리고 오른쪽 마우스를 눌러서 'Compare with>Each Other을 눌러준다

그러면 아래와 같이 정답지와 비교해준다~!

 

위와같이 수정하였는데 또다른 오류가 발생하였다!!

ERROR 4612 --- [testProject2] [nio-8083-exec-6] o.a.c.c.C.[.[.[/].[dispatcherServlet]  : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed: org.thymeleaf.exceptions.TemplateInputException: Error resolving template [member/memberInfo], template might not exist or might not be accessible by any of the configured Template Resolvers] with root cause

 

org.thymeleaf.exceptions.TemplateInputException: Error resolving template [member/memberInfo], template might not exist or might not be accessible by any of the configured Template Resolvers

 

위 오류는 아직 찾지 못했다. 찾아보고 다시 작성하도록 하겠다!!

 

하루가 지나고 드디어 위에 오류를 찾아 냈다!!

폴더명 네임과 과 html파일 내 이름이 다른 것이였다

[해결된 화면]

 


 th:block 태그

- Thymeleaf에서 제공하는 유일한 태그

- Thymeleaf는 태그 내에 th 속성을 작성하여 정의하는게 일반적이지만 

   th속성을 작성할 태그가 존재하지 않을 때 사용

- th:text 보단 조건, 반복문과 같이 사용하는 경우가 많음

✅ Spring 같은 경우 getter 가 필수로 있어야 함

-> ${Student DTO.getName()} == ${StudentDTO.name}