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

这里articleText就是我们后端setAttribute进去的
然后就能成功渲染页面上去
相关推荐
2023-06-03
java图片切片
女人绝不会被奉承解除武装,而男人大都会陷落。——王尔德 可以使用hutool的ImgUtil.slice 1ImgUtil.slice(FileUtil.file("d:/test/logo.jpg"), FileUtil.file("d:/test/dest"), 200, 150); 123456789 /** * 图像切片(指定切片的宽度和高度) * * @param srcImageFile 源图像 * @param descDir 切片目标文件夹 * @param destWidth 目标切片宽度。默认200 * @param destHeight 目标切片高度。默认150 */public static void slice(final File srcImageFile, final File descDir, final int destWidth, final int destHeight) 而且除了指定宽度和高度的,还可以使用: 12345678910/** * 图像切割(指定切片的行数和列数...
2021-10-31
lombok注解
秣秩斯干,幽幽南山。如竹苞矣,如松茂矣。——《诗经》 首先是官方文档,列举了所有注解 常用的我就不聊了,这里上代码聊聊不咋常用的 首先是@Cleanup注解,能够自动关闭流 12345678910111213public static String readFile(File file) throws Exception { StringBuilder builder = new StringBuilder(); @Cleanup InputStream is = new FileInputStream(file); String line; @Cleanup BufferedReader reader = new BufferedReader(new InputStreamReader(is)); line = reader.readLine(); while (line != null) { builder.append(line); builder.append("\n&quo...
2024-01-22
stream-query的BeanHelper拷贝支持Converter
锲而舍之,朽木不折;锲而不舍,金石可镂。——荀子 这还是个实验性功能,首先引入: 12345<dependency> <groupId>org.dromara.stream-query</groupId> <artifactId>stream-plugin-mybatis-plus</artifactId> <version>2.1.0-alpha</version></dependency> 然后对应的单元测试: 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211...
2022-05-15
引入一个boot模块坑
“所有你乐于挥霍的时间都不能算作是浪费。”——约翰·列侬 这个坑蛮棘手的 事发场景:main-boot引入common-boot模块,common-boot模块是一个spring-boot模块 关键GAV构成如下: common-boot 12345678910111213141516171819<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.6.7</version> <relativePath/></parent><groupId>com.ruben</groupId><artifactId>common-boot</artifactId><version>0.0.1-SNAPSHOT</ver...
2022-11-28
mybatis-plus代码方式配置
发光的不全是黄金——莎士比亚 示例:https://github.com/apache/incubator-streampark/pull/2099 原来的方式: 1234567891011# mybatis plus settingmybatis-plus: type-aliases-package: org.apache.streampark.console.*.entity mapper-locations: classpath:mapper/*/*.xml configuration: jdbc-type-for-null: null global-config: db-config: id-type: auto # close mybatis-plus banner banner: false 现在的方式: 123456789101112131415161718192021/** * mybatis plus setting * * @return MybatisPlusPropertiesCustomi...
2023-04-02
h2-console
名枪好躲,暗箭难防。——无名氏 分享一个h2-console的使用方式: 首先配置: 1234spring: h2: console: enabled: true 然后可以看到日志: 我们访问localhost:8080/h2-console,复制jdbc:h2:mem:2e01066c-fbfb-40a5-8ba9-3ff049d753f8到connection url 进到控制台,并成功连接 这里可以看到我们的库表信息以及进行查询 非常的好用
