我已经构建了一个简单的 SpringBoot 应用程序,如下所述: https://spring.io/guides/gs/spring-boot/
我能够使其正常工作并测试了所有端点,包括 /hello,它需要用户登录才能访问。
然后我尝试通过在子文件夹内添加新端点来扩展此应用程序。 为此,我创建了文件夹“/src/main/resources/templates/client”,并在该文件夹中放置了一个 index.html 文件。 我在控制器中添加了相应的路由,如下所示:
@Controller
public class DefaultController {
@GetMapping("/client")
public String client( ) {
return "client/index";
}
....
当我访问http://localhost:8080/client时
我得到的错误是:
解析模板 [client/index] 时出错,模板可能不存在或 任何已配置的模板解析器可能无法访问 org.thymeleaf.exceptions.TemplateInputException:解决错误 模板[客户/索引],
我该如何纠正这个问题?
模板名称是
index
,应该解析
@GetMapping("/client")
public String client( ) {
return "index";
}