@Configuration
public class ThymeleafConfigration { @Bean
public SpringResourceTemplateResolver firstTemplateResolver() {
SpringResourceTemplateResolver templateResolver = new SpringResourceTemplateResolver();
//templateResolver.setPrefix("classpath:/templates2/"); File path = null;
try {
path = new File(ResourceUtils.getURL("classpath:").getPath());
//file:/data/github/testmanagement/target/testmanagement-0.0.1-SNAPSHOT.jar!/BOOT-INF/classes!
System.out.println(path.getPath());
} catch (FileNotFoundException e) {
e.printStackTrace();
}
//server.tomcat.basedir=outsidefile/jacococoverage
String outside_templates=path.getParentFile().getParentFile().getParent()+File.separator;
//String outside_templates=path.getParentFile().getParentFile().getParent()+File.separator+"outsidefile"+File.separator+"jacococoverage"+File.separator; System.out.println(outside_templates);
outside_templates=outside_templates.substring(5,outside_templates.length());
//file:/data/github/testmanagement/target/outsidefile/jacococoverage/ System.out.println("new outside_templates is "+outside_templates);
templateResolver.setPrefix("file://"+outside_templates); templateResolver.setSuffix(".html");
templateResolver.setTemplateMode(TemplateMode.HTML);
templateResolver.setCharacterEncoding("UTF-8");
// templateResolver.setOrder(0);
templateResolver.setCheckExistence(true); //Spring Boot中Thymeleaf引擎动态刷新
templateResolver.setCacheable(false);
return templateResolver;
} // @Bean
// public ClassLoaderTemplateResolver secondaryTemplateResolver() {
// ClassLoaderTemplateResolver secondaryTemplateResolver = new ClassLoaderTemplateResolver();
// secondaryTemplateResolver.setPrefix("templates-2/");
// secondaryTemplateResolver.setSuffix(".html");
// secondaryTemplateResolver.setTemplateMode(TemplateMode.HTML);
// secondaryTemplateResolver.setCharacterEncoding("UTF-8");
// secondaryTemplateResolver.setOrder(1);
// secondaryTemplateResolver.setCheckExistence(true);
//
// return secondaryTemplateResolver;
// }
}

SpringBoot Thymeleaf 配置多个Template Locations的更多相关文章

  1. IDEA SpringBoot +thymeleaf配置

    1.pom添加以下依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactI ...

  2. springboot+maven+thymeleaf配置实战demo

    本案例使用thymeleaf,与springboot配置使用.thymeleaf是一种模板语言,可以动态或者静态显示文本内容. 1 .项目结构 2.构建springboot项目 通过idea的new ...

  3. Thymeleaf Multiple Template Locations using Spring Boot

    1. Overview In this tutorial, we'll see how we can define multiple template locations using Thymelea ...

  4. SpringBoot自动配置探究

    @SpringBootApplication @SpringBootApplication表示SpringBoot应用,标注在某个类上说明这个类是SpringBoot的主配置类,SpringBoot就 ...

  5. springboot 详细配置2

    # =================================================================== # COMMON SPRING BOOT PROPERTIE ...

  6. springboot中配置主从redis

    测试redis的主从配置 redis实例 文件夹名称如下 redis_master_s redis_slaver1_s redis_slaver2_s redis.conf文件 master的redi ...

  7. 浅谈springboot自动配置原理

    前言 springboot自动配置关键在于@SpringBootApplication注解,启动类之所以作为项目启动的入口,也是因为该注解,下面浅谈下这个注解的作用和实现原理 @SpringBootA ...

  8. SpringBoot下配置FreeMarker配置远程模版

    需求产生原因 要求在同一个接口中,根据不同的参数,返回不同的视图结果 所有的视图中的数据基本一致 要求页面能静态化,优化SEO 例如:A接口返回客户的信息 客户A在调用接口时,返回其个性化定制的页面A ...

  9. SpringBoot+thymeleaf+security+vue搭建后台框架 基础篇(一)

    刚刚接触SpringBoot,说说踩过的坑,主要的还是要记录下来,供以后反省反省! 今天主要讲讲 thymeleaf+security 的搭建,SpringBoot的项目搭建应该比较简单,这里就不多说 ...

随机推荐

  1. 搭建vue.js 的npm脚手架

    1.在cmd中,找到nodeJs安装的路径下,运行 vue -V,查看当前vue版本,如下图所示,表明已经安装过了. 2.没有安装,进行安装.在cmd中,找到nodeJs安装的路径下,运命令行 npm ...

  2. mac下JDK的安装路径

    苹果系统已经包含完整的J2SE,其中就有JDK和JVM(苹果叫VM).当然如果要升级JDK,那当然要自己下载安装了. 在MAC系统中,jdk的安装路径与windows不同,默认目录是:/System/ ...

  3. OpenResty 执行流程阶段

    nginx有11个处理阶段,如下图所示: 指令 所处处理阶段 使用范围 解释 init_by_luainit_by_lua_file loading-config http nginx Master进 ...

  4. Delphi 图像组件(Image)

    樊伟胜

  5. pandas中Series对象下的str所拥有的方法(df["xx"].str)

    在使用pandas的时候,经常要对DataFrame的某一列进行操作,一般都会使用df["xx"].str下的方法,但是都有哪些方法呢?我们下面来罗列并演示一下.既然是df[&qu ...

  6. linux 启动tomcat

    操作步骤: 第一步:进入tomcat的bin目录 cd /usr/local/tomcat/bin 第二步:使用tomcat关闭命令 ./shutdown.sh 第三步:查看tomcat是否关闭 ps ...

  7. Hdu 1517 巴什博奕变形

    易知2-9为先手胜 继续递推下去 10-18 后手胜 再推发现19-162先手胜 即发现有9(9) 18(2*9) 162(9*2*9)..... #include<bits/stdc++.h& ...

  8. struts2使用注解的时候遇到的问题

    问题描述:     一切配置和注解都正确,但是无法访问action中的方法   解决问题:     之前将action层的包名命名成了web,改成action就对了   原因:     struts2 ...

  9. python小练手题1

    1. """ Write a program which can compute the factorial of a given numbers. The result ...

  10. HTML5的快捷方式

    ctrl + /  单行注释 ctrl + shift + /   块注释 ctrl + shift + “+”   展开 ctrl + shift + “-”  折叠 ctrl + alt + L  ...