공부 메모

스프링부트 Spring Boot 500에러 해결 방법

Hicecream 2023. 11. 7. 20:51

 

[사건 발달]

 

인텔리제이에서 스프링부트로 회원가입 로그인 기능을 만들고 있었다.

 

Application 파일을 실행하였더니 로컬호스트 페이지에서 아래와 같은 500 오류가 나면서 내가 원하는 회원가입, 로그인 html 페이지가 뜨지 않았다.

Whitelabel Error Page

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

Tue Nov 07 20:26:26 KST 2023
There was an unexpected error (type=Internal Server Error, status=500).
Error resolving template [/index], template might not exist or might not be accessible by any of the configured Template Resolvers
org.thymeleaf.exceptions.TemplateInputException: Error resolving template [/index], template might not exist or might not be accessible by any of the configured Template Resolvers
at org.thymeleaf.engine.TemplateManager.resolveTemplate(TemplateManager.java:869)
at org.thymeleaf.engine.TemplateManager.parseAndProcess(TemplateManager.java:607)
at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1103)
at org.thymeleaf.TemplateEngine.process(TemplateEngine.java:1077)

...

 

 

인텔리제이에서도 마찬가지로 에러가 났다고 알려줬다.

2023-11-07T20:26:26.266+09:00 ERROR 4744 --- [nio-8081-exec-3] 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 [/index], 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 [/index], template might not exist or might not be accessible by any of the configured Template Resolvers
at org.thymeleaf.engine.TemplateManager.resolveTemplate(TemplateManager.java:869) ~[thymeleaf-3.1.2.RELEASE.jar:3.1.2.RELEASE]
at org.thymeleaf.engine.TemplateManager.parseAndProcess(TemplateManager.java:607) ~[thymeleaf-3.1.2.RELEASE.jar:3.1.2.RELEASE]
...

 

 

 

[해결 방법]

 

 

Controller 메서드에서 return 반환값에 "MVC 뷰 'save'을(를) 해결할 수 없습니다"

이런 경고문이 뜨는 사람은 주목!!!!

 

 

원인은 바로 html 파일의 위치를 알 수 없어서 나타나는 문제였다..!

나 같은 경우엔 static 폴더에 html 파일이 있었는데, 이를 templates 파일로 옮기면 해결된다.

 

 

 

이렇게 페이지가 잘 뜬다ㅠㅠ

 

 

return 값에서 "MVC 뷰 'save'을(를) 해결할 수 없습니다"의 문구가 없어지고, Ctrl+마우스 클릭을 해보면 해당 html 파일로 이동도 할 수 있다. 

 

 

 

 

[느낀점]

 

html 파일 위치가 이상했던 이유.. 여러가지 알아보다가 html 파일은 templates가 아니라 static에 있어야 된다는 글을 많이 봐서 저렇게 옮겨놓은 거였다.. 그걸 까먹고 뭐가 문제지 하면서 엄청 헤맸다.... 서치를 엄청 해봐도 이유를 모르겠어서 결국 혼자 해결했다 하하..