gpt4 book ai didi

spring-boot - Thymeleaf - 检查模板是否存在

转载 作者:行者123 更新时间:2023-12-03 19:33:20 26 4
gpt4 key购买 nike

我正在寻找一种方法来检查模板是否存在,然后再将它返回到带有 Thymeleaf 和 Spring 的 View 中。

在我的 Controller 中,我试图做这样的事情:

String finalTemplate = template.getPrefix() + "/" + templateName;

try {
return finalTemplate;
} catch(TemplateInputException e) {
logger.debug("Sono qua");
return templateName;
}

但异常(exception)不是catch ...

最佳答案

您在此处处理异常的方式不适用于模板异常。

在问题部分 github 中检查以下线程。

https://github.com/thymeleaf/thymeleaf-spring/issues/94

https://github.com/thymeleaf/thymeleaf-spring/issues/81

关于spring-boot - Thymeleaf - 检查模板是否存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52139371/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com