当前位置: 代码迷 >> 综合 >> Spring Boot 报错:Error resolving template template might not exist or might not be accessible
  详细解决方案

Spring Boot 报错:Error resolving template template might not exist or might not be accessible

热度:49   发布时间:2023-11-25 00:30:57.0

在使用spring boot搭建项目的时候报错:

Error resolving template template might not exist or might not be accessible

解决方法:

情况1:

public String thymeleaf(Model model){model.addAttribute("name", "mark");return "hello ";
}

仔细观察后发现:

"hello "中多了一个空格..改成“hello”即OK。

情况2:

public String thymeleaf(Model model){model.addAttribute("name", "mark");return "/hello";
}

在springboot中使用thymeleaf不需要加“/xxxx”

同样的改成:

public String thymeleaf(Model model){model.addAttribute("name", "mark");return "hello";
}

就OK

  相关解决方案