//前端html
<!DOCTYPE html>
<html lang="en"> <head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="../static-recourse/css/home.css" />
<link rel="stylesheet" href="../static-recourse/layui/layui.css" />
<link rel="stylesheet" href="../static-recourse/css/guide.css"/>
<script src="../static-recourse/js/jquery.min.js"></script>
<title>网站首页</title>
<style>
.query .notFount {
display: none;
} .unitList p a {
margin-bottom: -4px;
} .unitList ul li {
margin-left: 32px;
margin-right: 4px;
} .unitList li p {
margin: 12px auto;
} .unitInform .unitInf,
.unitInform .printInf {
margin-left: 50px;
} .unitInform .unitInf p {
margin-top: 18px;
font-size: 12px;
} .unitInform h3 {
margin-top: 30px;
} .unitInform .printList p {
margin-top: 20px;
font-size: 12px;
} .unitInform input[type="button"] {
margin-bottom: -6px;
} .unitInform {
display: none;
}
.rules{
width: 49%;
float: left;
}
.standar{
width: 49%;
float: left;
margin-left: 18px;
}
.leftspan{
width: 49%;
float: left;
}
</style>
</head> <body>
<div class="content">
<div class="content layui-row layui-col-space9">
<div class="content_w serviceTable type_1_content rules">
<span class="title">新闻资讯</span>
<table class="layui-table service">
<colgroup>
<col width="250">
<col width="50">
<col>
</colgroup>
<!--<thead>
<tr>
<th>标题</th>
<th>时间</th>
</tr>
</thead>-->
<tbody id="guidance-list" class="guidance-list">
<tr th:each="var,varStat : ${xwzxList}" th:if="${varStat.index} lt 5">
<td class="titleTr">
<span th:if="${var.isTop}"><img src="../static-recourse/img/pin_1.gif" style="padding-right: 5px;"/></span>
<span th:if="${not var.isTop}"><img src="../static-recourse/img/folder_new.gif" style="padding-right: 5px;"/></span>
<a th:utext="${var.title}" th:attr="data-id=${var.id},title=${var.title}">关于推进全国统一 “多证合一”改革的意见</a>
</td>
<td class="checkTr" th:text="${#dates.format(var.updateTime,'yyyy-MM-dd')}">2019-01-01</td>
</tr>
<tr th:each="i:${#numbers.sequence(1,5-xwzxList.size())}" th:if="${xwzxList.size()} lt 5">
<td class="titleTr"><a>&nbsp;</a></td>
<td class="checkTr">&nbsp;</td>
</tr>
<tr>
<td class="titleTr"><a href="new_guide.html?flag=0" target="_parent">更多>></a></td>
<td class="checkTr">&nbsp;</td>
</tr>
</tbody>
</table>
</div> <div class="content_w serviceTable type_2_content standar">
<span class="title">政策法规</span>
<table class="layui-table service">
<colgroup>
<col width="250">
<col width="50">
<col>
</colgroup>
<!--<thead>
<tr>
<th>标题</th>
<th>时间</th>
</tr>
</thead>-->
<tbody id="guidance-list" class="guidance-list">
<tr th:each="var,varStat : ${zcfgList}" th:if="${varStat.index} lt 5">
<td class="titleTr">
<span th:if="${var.isTop}"><img src="../static-recourse/img/pin_1.gif" style="padding-right: 5px;"/></span>
<span th:if="${not var.isTop}"><img src="../static-recourse/img/folder_new.gif" style="padding-right: 5px;"/></span>
<a th:utext="${var.title}" th:attr="data-id=${var.id},title=${var.title}">关于推进全国统一 “多证合一”改革的意见</a>
</td>
<td class="checkTr" th:text="${#dates.format(var.updateTime,'yyyy-MM-dd')}">2019-01-01</td>
</tr>
<tr th:each="i:${#numbers.sequence(1,5-zcfgList.size())}" th:if="${zcfgList.size()} lt 5">
<td class="titleTr"><a>&nbsp;</a></td>
<td class="checkTr">&nbsp;</td>
</tr>
<tr>
<td class="titleTr"><a href="new_guide.html?flag=1" target="_parent">更多>></a></td>
<td class="checkTr">&nbsp;</td>
</tr>
</tbody>
</table>
</div> <div class="content_w serviceTable type_2_content leftspan">
<span class="title">行业标准</span>
<table class="layui-table service">
<colgroup>
<col width="250">
<col width="50">
<col>
</colgroup>
<!--<thead>
<tr>
<th>标题</th>
<th>时间</th>
</tr>
</thead>-->
<tbody id="guidance-list" class="guidance-list">
<tr th:each="var,varStat : ${hybzList}" th:if="${varStat.index} lt 5">
<td class="titleTr">
<span th:if="${var.isTop}"><img src="../static-recourse/img/pin_1.gif" style="padding-right: 5px;"/></span>
<span th:if="${not var.isTop}"><img src="../static-recourse/img/folder_new.gif" style="padding-right: 5px;"/></span>
<a th:utext="${var.title}" th:attr="data-id=${var.id},title=${var.title}">关于推进全国统一 “多证合一”改革的意见</a>
</td>
<td class="checkTr" th:text="${#dates.format(var.updateTime,'yyyy-MM-dd')}">2019-01-01</td>
</tr>
<tr th:each="i:${#numbers.sequence(1,5-hybzList.size())}" th:if="${hybzList.size()} lt 5">
<td class="titleTr"><a>&nbsp;</a></td>
<td class="checkTr">&nbsp;</td>
</tr>
<tr>
<td class="titleTr"><a href="new_guide.html?flag=2" target="_parent">更多>></a></td>
<td class="checkTr">&nbsp;</td>
</tr>
</tbody>
</table>
</div> <div class="content_w serviceTable type_2_content standar">
<span class="title">知识园地</span>
<table class="layui-table service">
<colgroup>
<col width="250">
<col width="50">
<col>
</colgroup>
<!--<thead>
<tr>
<th>标题</th>
<th>时间</th>
</tr>
</thead>-->
<tbody id="guidance-list" class="guidance-list">
<tr th:each="var,varStat : ${zsydList}" th:if="${varStat.index} lt 5">
<td class="titleTr">
<span th:if="${var.isTop}"><img src="../static-recourse/img/pin_1.gif" style="padding-right: 5px;"/></span>
<span th:if="${not var.isTop}"><img src="../static-recourse/img/folder_new.gif" style="padding-right: 5px;"/></span>
<a th:utext="${var.title}" th:attr="data-id=${var.id},title=${var.title}">关于推进全国统一 “多证合一”改革的意见</a>
</td>
<td class="checkTr" th:text="${#dates.format(var.updateTime,'yyyy-MM-dd')}">2019-01-01</td>
</tr>
<tr th:each="i:${#numbers.sequence(1,5-zsydList.size())}" th:if="${zsydList.size()} lt 5">
<td class="titleTr"><a>&nbsp;</a></td>
<td class="checkTr">&nbsp;</td>
</tr>
<tr>
<td class="titleTr"><a href="new_guide.html?flag=3" target="_parent">更多>></a></td>
<td class="checkTr">&nbsp;</td>
</tr>
</tbody>
</table>
</div>
</div> </div>
</body>
<script th:inline="javascript">
   // 后台数据传输到js变量中
   var down_url = [[${downUrl}]];
   var arry = [];
   arry = [[${FileList}]];
// 查看每条记录
$(".guidance-list").on('click', 'a', function () {
var id = $(this).attr("data-id");
if(id){
window.open('details/'+id+'.html','_blank');// 详情跳转
}
})
</script>
</html>
//END-前端html

//后端写操作
package com.dhht.service; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.thymeleaf.TemplateEngine;
import org.thymeleaf.context.Context; import javax.annotation.Resource;
import java.io.File;
import java.io.PrintWriter;
import java.util.Map; /**
* @Author: sh
* @Description: PageCacheService
* @Date: 14:25 2019/9/24
*/
@Slf4j
@Service
public class PageCacheService { static String CACHE_FILE_SUFFIX = ".html"; @Value("${regulation_path}")
String REGULATION_PATH;// 缓存页面磁盘路径 @Value("${regulation_temp_source}")
String REGULATION_TEMP_SOURCE; @Resource
private TemplateEngine templateEngine; /**
* 模板数据填充
*
* @param valsMap
* @param templateId
*/
public void setValToTemplat(Map<String, Object> valsMap, String templateId) {
setVals(valsMap,templateId,templateId,REGULATION_PATH);
} /**
* 数据填充
*
* @param val 填充值
* @param tempId 模板id
* @param regulationId 资讯id
* @param tarDir 本地磁盘目录
*/
public void setVals(Map<String, Object> val, String tempId, String regulationId, String tarDir) {
PrintWriter writer = null;
try {
Context context = new Context();
context.setVariables(val);
File dirPath = new File(tarDir);
if (!dirPath.exists()) {
dirPath.mkdirs();
}
File uploadFile = new File(tarDir, regulationId + CACHE_FILE_SUFFIX);// ResourceUtils.getFile("classpath:templates/" + templateId + ".html");
if (uploadFile.exists()) {
uploadFile.delete();
}
writer = new PrintWriter(uploadFile, "UTF-8");
// 生成html,第一个参数是thymeleaf页面下的原型名称
templateEngine.process(tempId, context, writer);
} catch (Exception e) {
log.error(e.getMessage());
} finally {
if(null!=writer){
writer.close();
}
}
}
}
package com.dhht.service;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.thymeleaf.TemplateEngine;
import org.thymeleaf.context.Context; import javax.annotation.Resource;
import java.io.File;
import java.io.PrintWriter;
import java.util.Map; /**
* @Author: sh
* @Description: PageCacheService
* @Date: 14:25 2019/9/24
*/
@Slf4j
@Service
public class PageCacheService { static String CACHE_FILE_SUFFIX = ".html"; @Value("${regulation_path}")
String REGULATION_PATH;// 缓存页面磁盘路径 @Value("${regulation_temp_source}")
String REGULATION_TEMP_SOURCE; @Resource
private TemplateEngine templateEngine; /**
* 模板数据填充
*
* @param valsMap
* @param templateId
*/
public void setValToTemplat(Map<String, Object> valsMap, String templateId) {
setVals(valsMap,templateId,templateId,REGULATION_PATH);
} /**
* 数据填充
*
* @param val 填充值
* @param tempId 模板id
* @param regulationId 资讯id
* @param tarDir 本地磁盘目录
*/
public void setVals(Map<String, Object> val, String tempId, String regulationId, String tarDir) {
PrintWriter writer = null;
try {
Context context = new Context();
context.setVariables(val);
File dirPath = new File(tarDir);
if (!dirPath.exists()) {
dirPath.mkdirs();
}
File uploadFile = new File(tarDir, regulationId + CACHE_FILE_SUFFIX);// ResourceUtils.getFile("classpath:templates/" + templateId + ".html");
if (uploadFile.exists()) {
uploadFile.delete();
}
writer = new PrintWriter(uploadFile, "UTF-8");
// 生成html,第一个参数是thymeleaf页面下的原型名称
templateEngine.process(tempId, context, writer);
} catch (Exception e) {
log.error(e.getMessage());
} finally {
if(null!=writer){
writer.close();
}
}
}
}

// 后台数据设置到js变量中var down_url = [[${downUrl}]];//"http://127.0.0.1:8080/downFile";var arry = [];arry = [[${FileList}]];

静态页面缓存(thymeleaf模板writer)的更多相关文章

  1. Spring Boot (4) 静态页面和Thymeleaf模板

    静态页面 spring boot项目只有src目录,没有webapp目录,会将静态访问(html/图片等)映射到其自动配置的静态目录,如下 /static /public /resources /ME ...

  2. 借助 Filter 生成静态页面缓存问题

    如果有些 jsp 页面,在一次 jsp 页面生成后 html 后, 就不太可能需要更新.可以使用缓存机制来解决这个问题. 解决思路如下 1.  定义一个文件夹 pagestaticize,用来存放 j ...

  3. 使用Varnish+ESI实现静态页面的局部缓存(思路篇)

    使用Varnish+ESI实现静态页面的局部缓存(思路篇) 页面静态化是搭建高性能网站必用的招式之一,页面静态化可以有效提升系统响应速度,同时也有利于搜索引擎优化.但在页面静态化后,静态页面之间包含( ...

  4. Nginx设置静态页面压缩和缓存过期时间的方法

    使用nginx服务器的朋友可能都知道需要设置html静态页面缓存与页面压缩与过期时间的设置了,下面我来给各位同学介绍一下配置方法,包括对ico,gif,bmp,jpg,jpeg,swf,js,css, ...

  5. Nginx设置静态页面压缩和缓存过期时间的方法 (转)

    使用nginx服务器的朋友可能都知道需要设置html静态页面缓存与页面压缩与过期时间的设置了,下面我来给各位同学介绍一下配置方法,包括对ico,gif,bmp,jpg,jpeg,swf,js,css, ...

  6. springboot-10-前端页面整合, thymeleaf, freemarker, jsp 模板使用

    springboot 中不建议使用jsp作为页面展示, 怎么使用可以看: http://412887952-qq-com.iteye.com/blog/2292471 关于什么是thymeleaf, ...

  7. 页面静态化3 --- 使用PHP页面缓存机制来完成页面静态化(下)操作一个案例(新闻管理系统)

    案例需求: 使用PHP缓存机制完成新闻管理系统的页面静态化数据库表 ecs_article (新闻表)因为新闻这些信息,并不是对实时性要求高,本身这个新闻比较稳定,内容也比较固定,所以我们考虑: 当第 ...

  8. (二)SpringBoot基础篇- 静态资源的访问及Thymeleaf模板引擎的使用

    一.描述 在应用系统开发的过程中,不可避免的需要使用静态资源(浏览器看的懂,他可以有变量,例:HTML页面,css样式文件,文本,属性文件,图片等): 并且SpringBoot内置了Thymeleaf ...

  9. SpringBoot入门篇--使用Thymeleaf模板引擎进行页面的渲染

    在做WEB开发的时候,我们不可避免的就是在前端页面之间进行跳转,中间进行数据的查询等等操作.我们在使用SpringBoot之前包括我在内其实大部分都是用的是JSP页面,可以说使用的已经很熟悉.但是我们 ...

随机推荐

  1. 备份CSDN

    说明:https://blog.csdn.net/Feynman1999/article/details/87908082 源码:https://github.com/Feynman1999/CSDN ...

  2. 第六篇 ORM 操作大全

    阅读目录(Content) 一 对象关系映射ORM概念 二 Django连接MySQL 三modles.py创建表 常用字段 字段合集 字段参数 DateField和DateTimeField 四.关 ...

  3. vue学习(十二)vue全家桶 Vue-router&Vuex

    一 vue-router的安装 二 vue-router的基本使用 三 命名路由 四 动态路由的匹配和路由组件的复用 一 vue-router的安装 NPM npm install vue-route ...

  4. Android之Intent相关知识

    什么是Intent?Intent的作用? Intent是一个消息传递对象,我们可以通过它来启动其他组件或者在组件之间传递数据. 通过Intent启动其他组件 Intent可以用来启动Activity, ...

  5. tensorflow--建立一个简单的小网络

    In [19]:           import tensorflow as tf import numpy as np # #简单的数据形网络 # #定义输入参数 # X=tf.constant( ...

  6. 每日一linux命令

    每日一linux命令 http://www.cnblogs.com/peida/tag/每日一linux命令/

  7. 前台图片Canvas压缩上传小结

    需求来源:之前有个提交审核表单的业务,表单中含有大量附件图片,大约有20多张吧,为了省事,采用的同步上传,一次需要上传很多照片,本来单张图片限制为200KB,这样子总图片大小约为5MB左右,想想也可以 ...

  8. swift 录音 AVAudioRecorder

    2018年05月16日 15:22:44 msmwncx阅读数:548 https://blog.csdn.net/msmwncx/article/details/80336973 版权声明:本文为博 ...

  9. 广义高斯分布(GGD)和非对称广义高斯分布(AGGD)

    <No-Reference Image Quality Assessment in the Spatial Domain>,BRISQUE. 1. 广义高斯分布,generalized G ...

  10. 【转载】Emdedding向量技术在蘑菇街推荐场景的应用

    花名:越祈 部门:算法中心搜索策略组 入职时间:2017/06/01 主要从事蘑菇街推荐算法相关研发工作 蘑菇街是一家社会化导购电商平台,推荐一直是其非常重要的流量入口.在电商平台中,推荐的场景覆盖到 ...