在js中获取thymeleaf变量(二)
发表于|更新于
|浏览量:
所谓天才,只不过是把别人喝咖啡的功夫都用在工作上了。——鲁迅
但比较繁琐
这次用简单的写法
1 | <script> |
非常简单~
不过要注意一点,如果是对象格式的数据,需要在script标签上加th:inline="javascript"
1 | <script th:inline="javascript"> |
在页面中也可以直接使用,可以代替th:text
1 | <div> |
效果如下

如果是字符串也支持的
1 | <div> |

相关推荐
2024-05-13
添加OceanBase-MybatisPlus案例
多思不若养志,多言不若守静,多才不若蓄德。——曾国藩 我在 ob-samples 添加的 demo 合并了 https://github.com/oceanbase/ob-samples/pull/37 通过 mybatisplus-java 启动和测试 OceanBase Docker容器,更多详细信息可以参见 https://github.com/baomidou/mybatis-plus以及 https://java.testcontainers.org/modules/databases/oceanbase 。 快速开始将 OceanBase 驱动、TestContainers OceanBase、MybatisPlusStarter、SpringBootStarter Test 模块添加到 POM。 12345678910111213141516171819202122232425262728293031323334353637383940414243444546<dependencies> <dependency> <grou...
2023-03-09
JOOL
感官并不欺骗人,欺骗人的是判断力——歌德 分享一个框架JOOL https://github.com/jOOQ/jOOL 其封装了更好用的lambda 例如: 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119// (1, 2, 3, 4, 5, 6)Seq.of(1, 2, 3).concat(Seq.of(4, 5, 6));// trueSeq.of(1, 2, 3, 4).contains(2);// trueSeq.of(1, 2, 3, 4).containsAll(2, 3);// trueSeq.of(1, 2, 3,...
2022-05-16
r2dbc
青春是有限的,智慧是无穷的,趁短的青春,去学习无穷的智慧。——高尔基 今天看了点R2DBC,官网:https://r2dbc.io/ Spring-Data-R2dbc:https://spring.io/projects/spring-data-r2dbc 学习文档:https://docs.spring.io/spring-data/r2dbc/docs/current/reference/html/ 跑了下demo,感觉还不错:https://gitee.com/VampireAchao/simple-r2dbc.git
2023-12-30
file获取路径区别
男人勤劳家才富,女人节俭纱成布——佚名 这里 12345678910111213import java.io.File;class Scratch { public static void main(String[] args) throws Exception { File file = new File("../scratch.java"); String path = file.getPath(); String absolutePath = file.getAbsolutePath(); String canonicalPath = file.getCanonicalPath(); System.out.println("path:" + path); System.out.println("absolutePath:" + absolutePath); System.out.print...
2020-12-23
@ModelAttribute
小人之过也必文。——《论语》 如果我们需要在controller执行前做一些事情,除了使用AOP外,我们还可以使用@ModelAttribute注解 被@ModelAttribute注解的方法会在controller执行前执行并把结果传递给了下面controller里我们注解的参数 实际开发中可以用来鉴权、过滤参数等 12345678910111213141516171819202122232425262728293031package com.ruben.controller;import org.springframework.web.bind.annotation.GetMapping;import org.springframework.web.bind.annotation.ModelAttribute;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RestController;/** * @...
2021-03-25
mybatis-plus默认查询方式
从善如登,从恶如崩。一一《国语》 我们在使用mybatis-plus条件构造器默认查询的时候 如果给的实体有值,则会根据实体内的值用对应字段去=查询 就像这样 12mpUserService.list(Wrappers.lambdaQuery(UserPO.builder().username("hino").build()));mpUserMapper.selectList(Wrappers.lambdaQuery(UserPO.builder().username("ruben").build())); 如果我们想要指定默认查询为LIKE 则可以在对应属性上加上注解@TableField并指定condition = SqlCondition.LIKE,就像这样 123456789101112131415161718192021222324252627282930package com.ruben.pojo.po;import com.baomidou.mybatisplus.annotation.*;import com.rube...
