zoukankan      html  css  js  c++  java
  • thymeleaf学习笔记

    1.导入thymeleaf名称空间

    <html lang="zh-Hans" xmlns:th="http://www.thymeleaf.org">

    2.thymeleaf语法

    2.1 循环遍历 th:each

    <div th:each="article,ArticleList:${articleList}"></div>

    2.2 三元运算

    解释:如果article.getArticleCover得到的值不是'' 则该div应用cover这个class属性否则noimg

    <div th:class="${article.getArticleCover()!=''}?cover:noimg">

    2.3 时间格式化

    <div class="stat" th:text="${#dates.format(article.getUpdateDate(), 'yyyy-MM-dd HH:mm:ss')}">

    示例

    <div class="article" th:each="article,ArticleBean:${articleList}">
                        <a th:href="'http://localhost:8080/p/'+${article.getArticleId()}+'.html'" target="_blank">
                            <div class="row">
                            <div class="title" th:text="${article.getArticleTitle()}">
    
                            </div>
                            <div th:class="${article.getArticleCover()!=''}?cover:noimg">
                                <img th:src="${article.getArticleCover()}" th:class="${article.getArticleCover()!=''}?img:noimg"/>
                            </div>
                            <div class="sketch" th:text="${article.getArticleSketch()}">
    
                            </div>
                            <div class="other">
                                <div class="icon">
                                    <span class="glyphicon glyphicon-user" aria-hidden="true"></span>
                                </div>
                                <div class="stat" th:text="${article.getArticleAuthor()}">
    
                                </div>
                                <div class="icon">
                                    <span class="glyphicon glyphicon-eye-open" aria-hidden="true"></span>
                                </div>
                                <div class="stat" th:text="${article.getArticleReadNum()}">
    
                                </div>
                                <div class="icon">
                                    <span class="glyphicon glyphicon-tag" aria-hidden="true"></span>
                                </div>
                                <div class="stat next" th:text="${article.getArticleLabel()}">
    
                                </div>
                                <div class="icon">
                                    <span class="glyphicon glyphicon-time" aria-hidden="true"></span>
                                </div>
                                <div class="stat" th:text="${#dates.format(article.getUpdateDate(), 'yyyy-MM-dd HH:mm:ss')}">
    
                                </div>
                            </div>
                            </div>
                        </a>
                    </div>
  • 相关阅读:
    尖峰冲击测试(spike Testing)
    mysql返回记录的ROWNUM(转)
    SQL2005四个排名函数(row_number、rank、dense_rank和ntile)的比较
    JUnit编写单元测试代码注意点小结
    Linux下Tomcat的启动、关闭、杀死进程
    linux下oracle11g R2的启动与关闭监听、数据库
    linux下使用yum安装mysql详解
    VC++ 实现文件与应用程序关联
    C++ 去掉字符串首尾的 x20 字符
    VC++ 线程同步 总结
  • 原文地址:https://www.cnblogs.com/ushowtime/p/11644861.html
Copyright © 2011-2022 走看看