Spring boot 如何使用thymeleaf+;弹簧靴?
我有一个项目,我需要用户能够添加内容,而无需重新编译应用程序或使用数据库。我想要实现的是spring在名为Spring boot 如何使用thymeleaf+;弹簧靴?,spring-boot,thymeleaf,Spring Boot,Thymeleaf,我有一个项目,我需要用户能够添加内容,而无需重新编译应用程序或使用数据库。我想要实现的是spring在名为modules/的目录中查找包含thymeleaf html文件的所有文件夹,并根据它们的名称从单个控制器中呈现它们。有可能吗 我已经查找了有关如何从java实时呈现thymeleaf片段的信息,但没有找到任何信息。借助于此,我们可以根据所需位置导航模板路径 @Bean public ClassLoaderTemplateResolver templateResolver() {
modules/
的目录中查找包含thymeleaf html文件的所有文件夹,并根据它们的名称从单个控制器中呈现它们。有可能吗
我已经查找了有关如何从java实时呈现thymeleaf片段的信息,但没有找到任何信息。借助于此,我们可以根据所需位置导航模板路径
@Bean
public ClassLoaderTemplateResolver templateResolver() {
ClassLoaderTemplateResolver templateResolver = new ClassLoaderTemplateResolver();
templateResolver().setPrefix("file://C:/test/");// this is
templateResolver.setCacheable(false);
templateResolver.setTemplateMode("HTML5");
templateResolver.setSuffix(".html");
templateResolver.setTemplateMode("XHTML");
templateResolver.setCharacterEncoding("UTF-8");
templateResolver.setOrder(1);
return templateResolver;
}
这也是一个解决办法。
在应用程序属性文件中使用此选项
project.base-dir=file:///E:/Work/WorkSpace/RND WorkSpace/sk
spring.thymeleaf.prefix=${project.base-dir}/src/main/resources/templates/
如果可能的话,你能提供一个例子,最好是一些相关的数据和代码吗?我不确定我是否理解你想要实现的目标。