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>
  • 相关阅读:
    ci中使用mail类
    简单php发送邮件
    Firefox 中出现的 “Network Protocol Error”怎么办
    让linux启动更快的方法
    小米盒子3代码公布了,你要刷机吗?
    毕业季,我的Linux求职之路
    菜鸟学习计划浅谈之Linux系统
    细述:nginx http内核模块提供的变量和解释
    Linux使用百度云
    网工的Linux系统学习历程
  • 原文地址:https://www.cnblogs.com/ushowtime/p/11644861.html
Copyright © 2011-2022 走看看