精品专区-精品自拍9-精品自拍三级乱伦-精品自拍视频-精品自拍视频曝光-精品自拍小视频

網站建設資訊

NEWS

網站建設資訊

Thymeleaf模板引擎怎么使用

今天小編給大家分享一下Thymeleaf模板引擎怎么使用的相關知識點,內容詳細,邏輯清晰,相信大部分人都還太了解這方面的知識,所以分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后有所收獲,下面我們一起來了解一下吧。

作為一家“創意+整合+營銷”的成都網站建設機構,我們在業內良好的客戶口碑。創新互聯建站提供從前期的網站品牌分析策劃、網站設計、網站設計制作、成都做網站、創意表現、網頁制作、系統開發以及后續網站營銷運營等一系列服務,幫助企業打造創新的互聯網品牌經營模式與有效的網絡營銷方法,創造更大的價值。

一、模板引擎

JSP、Velocity、Freemarker、Thymeleaf

Thymeleaf模板引擎怎么使用

二、springboot推薦使用Thymeleaf模板引擎

特點:語法更簡單,功能更強大;

1、引入Thymeleaf


            org.springframework.boot
            spring-boot-starter-thymeleaf
        

2、Thymeleaf的使用

@ConfigurationProperties(prefix = "spring.thymeleaf")
public class ThymeleafProperties {

    private static final Charset DEFAULT_ENCODING = Charset.forName("UTF-8");

    private static final MimeType DEFAULT_CONTENT_TYPE = MimeType.valueOf("text/html");

    public static final String DEFAULT_PREFIX = "classpath:/templates/";

    public static final String DEFAULT_SUFFIX = ".html";
只要我們把HTML頁面放在classpath:/templates/,thymeleaf就能自動渲染;

3、導入thymeleaf的名稱空間

4、使用thymeleaf語法




    
    Title


    

成功!

         這是顯示歡迎信息

三、語法規則

1、th:text;改變當前元素里面的文本內容;?th:任意html屬性;來替換原生屬性的值

Thymeleaf模板引擎怎么使用

2、表達式

Simple expressions:(表達式語法)
    Variable Expressions: ${...}:獲取變量值;OGNL;
            1)、獲取對象的屬性、調用方法
            2)、使用內置的基本對象:
                #ctx : the context object.
                #vars: the context variables.
                #locale : the context locale.
                #request : (only in Web Contexts) the HttpServletRequest object.
                #response : (only in Web Contexts) the HttpServletResponse object.
                #session : (only in Web Contexts) the HttpSession object.
                #servletContext : (only in Web Contexts) the ServletContext object.
                
                ${session.foo}
            3)、內置的一些工具對象:
#execInfo : information about the template being processed.
#messages : methods for obtaining externalized messages inside variables expressions, in the same way as they would be obtained using #{…} syntax.
#uris : methods for escaping parts of URLs/URIs
#conversions : methods for executing the configured conversion service (if any).
#dates : methods for java.util.Date objects: formatting, component extraction, etc.
#calendars : analogous to #dates , but for java.util.Calendar objects.
#numbers : methods for formatting numeric objects.
#strings : methods for String objects: contains, startsWith, prepending/appending, etc.
#objects : methods for objects in general.
#bools : methods for boolean evaluation.
#arrays : methods for arrays.
#lists : methods for lists.
#sets : methods for sets.
#maps : methods for maps.
#aggregates : methods for creating aggregates on arrays or collections.
#ids : methods for dealing with id attributes that might be repeated (for example, as a result of an iteration).

    Selection Variable Expressions: *{...}:選擇表達式:和${}在功能上是一樣;
        補充:配合 th:object="${session.user}:
   
    

Name: Sebastian.

    

Surname: Pepper.

    

Nationality: Saturn.

    
         Message Expressions: #{...}:獲取國際化內容     Link URL Expressions: @{...}:定義URL;             @{/order/process(execId=${execId},execType='FAST')}     Fragment Expressions: ~{...}:片段引用表達式             ...
             Literals(字面量)       Text literals: 'one text' , 'Another one!' ,…       Number literals: 0 , 34 , 3.0 , 12.3 ,…       Boolean literals: true , false       Null literal: null       Literal tokens: one , sometext , main ,… Text operations:(文本操作)     String concatenation: +     Literal substitutions: |The name is ${name}| Arithmetic operations:(數學運算)     Binary operators: + , - , * , / , %     Minus sign (unary operator): - Boolean operations:(布爾運算)     Binary operators: and , or     Boolean negation (unary operator): ! , not Comparisons and equality:(比較運算)     Comparators: > , < , >= , <= ( gt , lt , ge , le )     Equality operators: == , != ( eq , ne ) Conditional operators:條件運算(三元運算符)     If-then: (if) ? (then)     If-then-else: (if) ? (then) : (else)     Default: (value) ?: (defaultvalue) Special tokens:     No-Operation: _

以上就是“Thymeleaf模板引擎怎么使用”這篇文章的所有內容,感謝各位的閱讀!相信大家閱讀完這篇文章都有很大的收獲,小編每天都會為大家更新不同的知識,如果還想學習更多的知識,請關注創新互聯行業資訊頻道。


本文名稱:Thymeleaf模板引擎怎么使用
當前鏈接:http://m.jcarcd.cn/article/jphjch.html

其他資訊

主站蜘蛛池模板: 国产丰满老熟 | 国产免费爱在线观 | 精选国产911在线 | 欧美性爱插插网络 | 国产精品1区二区 | 精品国产90后 | 国产综合之 | 国产福利一区二区三 | 日韩精品在线开放 | 日韩新片王网 | 欧美日韩手机看片 | 国产欧洲在线播放 | 国产色成| 丝袜精品亚洲欧美 | 国产视频一区二区 | 福利在线观看 | 三级国产 | 老司机免费 | 国产人成视频 | 蜜桃视频一日韩欧 | 三级网页 | 精品91| 最新欧美精品一 | 国语第一次处破女 | 日韩日午夜人精品 | 欧美在线亚洲 | 91啦视频在线观看 | 区三区蜜桃 | 久综合网 | 国产精品精品精品 | 国产精品福利免费 | 美乳一区 | 日本视频一区二区 | 日本精a在线观看 | 92午夜福利 | 欧美日韩在线高清 | www国产亚洲精 | 中文字幕乱老妇 | 国产午夜福利在线 | 欧美最新免费一区 | 国产91综合 |