thymeleaf动态渲染html
发表于|更新于
|浏览量:
君子忍人所不能忍,容人所不能容,处人所不能处。——邓拓
我们可以使用thymeleaf进行动态渲染html内容
假设我的整个页面都是字符串,例如如下格式:
1 | "<!DOCTYPE html>\n" + |
那我们渲染的话,其实可以直接新建一个页面,用[(${page})]语法,例如
1 | [(${articleText})] |

这里articleText就是我们后端setAttribute进去的
然后就能成功渲染页面上去
相关推荐
2021-12-06
Collectors.toMap空指针问题
社会上崇敬名人,于是以为名人的话就是名言,却忘记了他所以得名是那一种学问和事业。 —— 鲁迅 对于Collectors.toMap,我们使用时如果value为空,则会抛出空指针,因为底层调用的Map.merge函数 如果我们想避免该问题,就可以使用collect去处理,例如我给hutool提交的这个PR一样 原先: 1StreamUtil.of(collection, isParallel).collect(Collectors.toMap(key, value, (l, r) -> l)); 现在: 1StreamUtil.of(collection, isParallel).collect(HashMap::new, (HashMap<K, V> m, E v) -> m.put(key.apply(v), value.apply(v)), HashMap::putAll); 完整函数: 12345678910111213141516/** * @param collection 需要转化的集合 * @param key E类型转...
2022-10-07
ballcat
对所有的人以诚相待,同多数人和睦相处,和少数人常来常往,只跟一个人亲密无间——富兰克林 分享一个简单的项目脚手架 官方文档:http://www.ballcat.cn/ gitee:https://gitee.com/ballcat-projects/ballcat github:https://github.com/ballcat-projects/ballcat 非常好用
2024-08-23
apache-shenyu适配oceanbase
不可乘快而多事,不可因倦而鲜终。——菜根谭 首先docker跑一个实例 123Github-Id-VampireAchao:~ achao$ docker run -p 2881:2881 --name shenyu-oceanbase -e MINI_MODE=0 -e ROOT_PASSWORD=12345678 -d oceanbase/oceanbase-ceed75d5a951daa4eaa8173c43bb65b27e1126f3063488ad1deafead941d6f2ff5Github-Id-VampireAchao:~ achao$ 由于oceanbase本身良好的语法兼容性,mysql模式语法不用修改,因此这里只针对驱动进行兼容 https://github.com/apache/shenyu/pull/5617 引入依赖: 12345<dependency> <groupId>com.oceanbase</groupId> <artifactId>oceanbase-client<...
2021-12-17
Thymeleaf Error resolving template [favicon.ico]
每一个看似简单的社会现象其实都只露出了冰山一角。——林达 遇到这个报错,方案1: 在页面上添加: 1<link rel="icon" href="/static/favicon.ico"> 前提是你有icon并且放到了static下面 方案2: 写个过滤器,给它过滤掉 12345678910111213141516171819202122232425262728293031323334353637package com.ruben.simplescaffold.filter;import cn.hutool.core.lang.Opt;import cn.hutool.core.text.CharSequenceUtil;import lombok.extern.slf4j.Slf4j;import org.springframework.stereotype.Component;import javax.servlet.*;import javax.servlet.annotation.WebFilter;import...
2024-03-27
stream-query开源合规
不好的书也像不好的朋友一样,可能把你戕害。——菲尔丁 首先是检查header的github action的ci 123456789101112131415161718192021222324252627282930313233343536373839404142# Licensed to the Apache Software Foundation (ASF) under one# or more contributor license agreements. See the NOTICE file# distributed with this work for additional information# regarding copyright ownership. The ASF licenses this file# to you under the Apache License, Version 2.0 (the# "License"); you may not use this file except in compliance# with...
2024-02-03
阿里云oss-cloud-sdk-springboot3兼容问题
辛勤的蜂蜜永远没有时间悲哀。——布莱克 前两天提到了: minio临时凭证直传切换到阿里云oss | 阿超 但是忘记说依赖和配置了,因为我本地是jdk17+springboot3,所以需要修改,首先是依赖: 123456<!-- https://mvnrepository.com/artifact/com.aliyun.oss/aliyun-sdk-oss --> <dependency> <groupId>com.aliyun.oss</groupId> <artifactId>aliyun-sdk-oss</artifactId> <version>3.17.4</version> </dependency> 按照我原来的博客里肯定是不行的 阿里云OSS临时凭证前后端配合上传文件 | 阿超 不能使用原来的 12345<dependency> <gr...

阿超
我的名字叫阿超 年龄25岁 家在北京市 职业是软件开发 每天最晚也会在八点前回家 不抽烟 酒浅尝辄止 晚上十二点上床 保证睡足八个小时 睡前写一篇博客 再做二十分钟俯卧撑暖身 然后再睡觉 基本能熟睡到天亮 像婴儿一样不留下任何疲劳和压力 就这样迎来第二天的早晨 健康检查结果也显示我很正常 我想说明我是一个不论何时都追求内心平稳的人 不拘泥于胜负 不纠结于烦恼 不树立使我夜不能寐的敌人 这就是我在这社会的生活态度
Follow Me公告
This is my Blog