thymeleaf new 创建对象

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/liyanlei5858/article/details/82179190

https://www.form1.cn/java-java-187.html

获取时间戳

1

<p th:text="${new java.util.Date().getTime()}"></p>

格式化时间

1

[[${#dates.format(new java.util.Date().getTime(), 'yyyy-MM-dd hh:mm:ss')}]]

注:[[${}]]这种格式为内联,你也可以使用th:text="${}"

以上为直接在thymeleaf中获取时间戳和格式化时间输入的实例

自己测试:

<div th:with="date1 = ${new java.util.Date()}" th:text="${date1.getTime()}"></div>
<div th:with="user = ${new com.lyl.test.User()}" th:text="${user.name}"></div>

猜你喜欢

转载自blog.csdn.net/liyanlei5858/article/details/82179190
今日推荐