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

myeonji·2022년 1월 27일
0

Error

목록 보기
3/8

실행이 잘 되고 있음에도 다른 웹 키고 다시 localhost:8080 들어오면 에러가 뜬다.

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

해결 ->

// 메인 페이지 (로그인 안 한 유저) /localhost:8080
    @GetMapping("/")
    public String mainPageNoneLogin(Model model) {
        // 로그인을 안 한 경우
        List<Item> items = itemService.allItemView();
        model.addAttribute("items", items);

        return "/main";
    }

"/main" 은 로그인 한 유저만 가능한 메인 페이지이다.
로그인 하지 않은 유저의 메인 페이지는 "/" 인데, 로그인 안 한 유저의 메인 페이지 Controller의 return을 "/main/"으로 하여 에러가 발생했던 것이다.
따라서 return "/main" -> return "main" 으로 바꾸어 리턴을 main.html로 변경 해주었다!

0개의 댓글