@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. Spring MVC之@RequestParam @RequestBody @RequestHeader 等详

    Spring MVC之@RequestParam @RequestBody @RequestHeader 等详     引言: 接上一篇文章,对@RequestMapping进行地址映射讲解之后,该篇 ...

  2. ASE19团队项目alpha阶段model组 scrum2 记录

    本次会议于11月4日,19时整在微软北京西二号楼sky garden召开,持续25分钟. 与会人员:Jiyan He, Kun Yan, Lei Chai, Linfeng Qi, Xueqing W ...

  3. textarea框自适应高度

    export function autoTextarea(elem, extra, maxHeight){ /**textarea文本域随内容的多少而调整高度 */ extra = extra || ...

  4. mysql数据库:分表、多表关联、外键约束、级联操作

    一.分表.外键.级联.多对一 二.多对多 三.一对一 一.分表.外键.级联.多对一 将部门数据与员工数据放到同一张表中会造成 数据重复 结构混乱 扩展维护性差 需要分表 create table de ...

  5. 关于C++跨平台

    问题:C++是怎么跨平台的呢? 答: 因为支持C++语言的各个平台的架构不同(比如CPU能够处理的指令集不一样),所以一份C++源代码要想在另一个操作系统平台上执行,就必须用该平台相对应的C++代码编 ...

  6. goquery 解析不了noscript

    今天在用goquery的时候 解析noscript标签的时候.发现一直获取不到里面的元素. google得到.需要去除noscript标签. s.Find("noscript"). ...

  7. Elasticsearch中Mapping

    映射(Mapping) 概念:创建索引时,可以预先定义字段的类型以及相关属性.从而使得索引建立得更加细致和完善.如果不预先设置映射,会自动识别输入的字段类型. 官方文档(字段数据类型):https:/ ...

  8. selenium+chromedriver+python3 不加载图片

    from selenium import webdriver chrome_options = webdriver.ChromeOptions() prefs={} chrome_opt.add_ex ...

  9. Scrapy爬取小说简单逻辑

    Scrapy爬取小说简单逻辑 一 准备工作 1)安装Python 2)安装PIP 3)安装scrapy 4)安装pywin32 5)安装VCForPython27.exe ........... 具体 ...

  10. USRPX310 在GNU Radio上更改通道A或B

    UHD:USRP sink和USRP source默认是A通道发射接收.或设置 Mb0:Subdev Spec: A:0 更改为B通道收发:设置 Mb0:Subdev Spec: B:0