SpringBoot Thymeleaf 配置多个Template Locations
@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的更多相关文章
- IDEA SpringBoot +thymeleaf配置
1.pom添加以下依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactI ...
- springboot+maven+thymeleaf配置实战demo
本案例使用thymeleaf,与springboot配置使用.thymeleaf是一种模板语言,可以动态或者静态显示文本内容. 1 .项目结构 2.构建springboot项目 通过idea的new ...
- Thymeleaf Multiple Template Locations using Spring Boot
1. Overview In this tutorial, we'll see how we can define multiple template locations using Thymelea ...
- SpringBoot自动配置探究
@SpringBootApplication @SpringBootApplication表示SpringBoot应用,标注在某个类上说明这个类是SpringBoot的主配置类,SpringBoot就 ...
- springboot 详细配置2
# =================================================================== # COMMON SPRING BOOT PROPERTIE ...
- springboot中配置主从redis
测试redis的主从配置 redis实例 文件夹名称如下 redis_master_s redis_slaver1_s redis_slaver2_s redis.conf文件 master的redi ...
- 浅谈springboot自动配置原理
前言 springboot自动配置关键在于@SpringBootApplication注解,启动类之所以作为项目启动的入口,也是因为该注解,下面浅谈下这个注解的作用和实现原理 @SpringBootA ...
- SpringBoot下配置FreeMarker配置远程模版
需求产生原因 要求在同一个接口中,根据不同的参数,返回不同的视图结果 所有的视图中的数据基本一致 要求页面能静态化,优化SEO 例如:A接口返回客户的信息 客户A在调用接口时,返回其个性化定制的页面A ...
- SpringBoot+thymeleaf+security+vue搭建后台框架 基础篇(一)
刚刚接触SpringBoot,说说踩过的坑,主要的还是要记录下来,供以后反省反省! 今天主要讲讲 thymeleaf+security 的搭建,SpringBoot的项目搭建应该比较简单,这里就不多说 ...
随机推荐
- Centos7:Redis的安装,配置及使用
安装依赖与环境 yum install gcc-c++ 解压缩redis 编译,进入redis源码目录 make 安装 make install PREFIX=/usr/local/redis 注:P ...
- js小功能2:切换
HTML: <div id="tb"> <ul><li class="on">房产</li><li> ...
- Centos搭建hexo教程
hexo文档:https://hexo.io/zh-cn/ 1.安装Git # sudo yum install git-core// 查看版本# git version// 输出git versio ...
- 1.移动端自动化测试-知识笔记(面试必备,测试点,adb命令)
移动端测试: 移动应用,特性(功能) 满足 需求(产品文档,隐性需求) 一.App功能测试: 死活背下来1.业务逻辑正确性测试: 产品文档,隐性需求- 写成测试用例 2.兼容性测试: 1.系统版本 ...
- JAVA语言程序设计课后习题----第一单元解析(仅供参考)
1 本题是水题,基本的输出语句 public class test { public static void main(String[] args) { // 相邻的两个 "" 要 ...
- Oracle【select from 语句】
Oracle[select from 语句] 1.select基本功能介绍1)投影操作:结果集是源表中的部分“列”2)选择操作:结果集是源表中的部分“行”3)选择操作+投影操作:结果集是源表中的部分 ...
- NORDIC 修改MTU
https://www.cnblogs.com/jiangjiu/p/10063556.html 注意要修改RAM起始地址,因为MTU增大了
- 建立一个能持续处理的C/S网络程序
程序流程图: 代码演示: 服务器端: #include<WinSock2.h> #include<Windows.h> #include<stdio.h> #inc ...
- Linux系统组成和获取命令帮助3
命令的语法通用格式: # COMMAND OPTIONS ARGUMENTS COMMAND: 发起一个命令:请求内核将某个二进制程序运行为一个进程 ...
- Linux日常之命令awk
参考:http://www.zsythink.net/archives/tag/awk/ 一. 命令awk简介 1. awk是一种编程语言,用于对文本和数据进行处理的 2. 具有强大的文本格式化能力 ...