@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. Docker 部署mysql、tomcat笔记

    Docker 笔记整理 #.环境:Ubuntu 18.* #.安装 mysql 5.6.tomcat #.docker search mysql 报错:Error response from daem ...

  2. 关于C++内存对齐

    关于C++内存对齐 C++11从标准层面引入了一些和内存对齐相关的特性,标准库也增加了对应的组件,这里稍微总结一下. 取得某个类型的对齐值 C++中的Object(对象)是指一块满足以下条件的内存区域 ...

  3. 修改Vue中的 v-html 内的元素无效问题

    其原因就是在 style 样式中没有去处scoped 因为 v-html 会把内容当成子组件,而scoped 会在本身的组件中起作用

  4. 并发编程J.U.C之AQS剖析

    一.j.u.c简介 在说主题AQS之前,我们有必要先来说一下J.U.C 顾名思义J.U.C就是java.util.concurrent,java并发工具包.由我们的并发大师老爷子Doug Lea亲自操 ...

  5. Oracle笔记(四) 简单查询、限定查询、数据的排序

    一.简单查询 SQL(Structured Query Language) 结构化查询语言,是一种数据库查询和程序设计语言,用于存取数据以及查询.更新和管理关系数据库系统.ANSI(美国国家标准学会) ...

  6. electron api sendInputEvent 源码

    electron-master\electron-master\shell\browser\api\atom_api_web_contents.cc // Copyright (c) 2014 Git ...

  7. 【转】(深入理解计算机系统) bss段,data段、text段、堆(heap)和栈(stack)

    bss段: bss段(bss segment)通常是指用来存放程序中未初始化的全局变量的一块内存区域. bss是英文Block Started by Symbol的简称. bss段属于静态内存分配. ...

  8. GitHub的本地与远程

    首先要有一个github账户(这不是废话吗) 在linux中先安装git arch linux : pacman -S git 在终端里输入 ssh-keygen ##一直默认就可以了 将公钥加入到G ...

  9. 数据库——Oracle(3)

    1 排序:对查询返回的结果,根据某一个列或者某几个列的列值大小进行升序或者降序排列. 1)根据某一个列的列值大小进行升序或者降序排列 格式: select 列名/* from 表名 order by ...

  10. 从零开始学会GAN 0:第一部分 介绍生成式深度学习(连载中)

    本书的前四章旨在介绍开始构建生成式深度学习模型所需的核心技术.在第1章中,我们将首先对生成式建模领域进行广泛的研究,并从概率的角度考虑我们试图解决的问题类型.然后,我们将探讨我们的基本概率生成模型的第 ...