美文网首页
HTML中的一些问题

HTML中的一些问题

作者: Tommmmm | 来源:发表于2018-09-06 23:09 被阅读0次

    一、Thymeleaf

    1、什么是Thymeleaf
    Thymeleaf是一个Java库,它是一个XML / XHTML / HTML5模板引擎。
    Thymeleaf的主要目标是提供一种优雅和高度可维护的创建模板的方式。

    2、Thymeleaf 的使用

    引用命名空间

    <html xmlns:th="http://www.thymeleaf.org"> 
    

    ${…} 表达式实际上是在上下文中包含的变量的执行的OGNL(Object-Graph Navigation Language)对象。

    变量

    <p>Today is: <span th:text="${today}">13 february 2011</span>.</p>
    // <span> 标签中的内容会被表达式${today}的值所替代
    

    URL

    <a th:href="@{http://www.thymeleaf.org}">Thymeleaf</a>
    

    字符串替换

    <span th:text="'Welcome to our application, ' + ${user.name} + '!'">
    

    IF/unless
    Thymeleaf中使用th:if和th:unless属性进行条件判断,上面的例子中,<div>标签只有在th:if中条件成立时才显示

    Switch

    <div th:switch="${user.role}">
      <p th:case="'admin'">User is an administrator</p>
      <p th:case="#{roles.manager}">User is a manager</p>
    </div>
    

    HTML中的class属性:
    <p class=“XX”>是给P标签加上了一个css样式
    可以把很多样式预先定义好,放在一个形如abc.css的文件中,然后在页面中根据需要使用其中已定义好的样式,这就是class。class告诉浏览器当前的对象使用的是哪个样式。

    相关文章

      网友评论

          本文标题:HTML中的一些问题

          本文链接:https://www.haomeiwen.com/subject/arfbsftx.html