<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                ## 4.1 內置方法 [TOC] ### 4.1.1 常用內置方法 - **date** 返回一個java.util.Date類型的變量,如 date() 返回一個當前時間(對應java的java.util.Date); ${date( "2011-1-1" , "yyyy-MM-dd" )} 返回指定日期 - **print** 打印一個對象 print(user.name); - **println** 打印一個對象以及回車換行符號,回車換號符號使用的是模板本身的,而不是本地系統的.如果僅僅打印一個換行符,則直接調用println() 即可 - **printFile** 直接答應文件,文件路徑以模板根目錄為相對目錄,printFile(‘‘/common/header.html’’); - **nvl** 函數nvl,如果對象為null,則返回第二個參數,否則,返回自己 nvl(user,"不存在") - **isEmpty** 判斷變量或者表達式是否為空,變量不存在,變量為null,變量是空字符串,變量是空集合,變量是空數組,此函數都將返回true - **isNotEmpty** 同上,判斷對象是否不為空 - has 變量名為參數,判斷是否存在此全局變量,如 has(userList),類似于1.x版本的exist("userList"),但不需要輸入引號了 - **assert** 如果表達式為false,則拋出異常 - trim 截取數字或者日期,返回字符,如trim(12.456,2)返回"12.45",trim(date,'yyyy')返回"2017" - **trunc** 截取數字,保留指定的小數位,如trunc(12.456,2) 輸出是12.45.不推薦使用,因為處理float有問題,兼容原因保留了 - **decode** 一個簡化的if else 結構,如 ${decode(a,1,"a=1",2,"a=2","不知道了")},如果a是1,這decode輸出"a=1",如果a是2,則輸出"a==2", 如果是其他值,則輸出"不知道了" - debug 在控制臺輸出debug指定的對象以及所在模板文件以及模板中的行數,如debug(1),則輸出1 [在3行@/org/beetl/core/lab/hello.txt],也可以輸出多個,如debug("hi",a),則輸出hi,a=123,[在3行@/org/beetl/core/lab/hello.txt] - **parseInt** 將數字或者字符解析為整形 如 parseInt("123"); - **parseLong** 將數字或者字符解析為長整形,parseInt(123.12); - **parseDouble** 將數字或者字符解析為浮點類型 如parseDouble("1.23") - **range** 接收三個參數,初始值,結束值,還有步增(可以不需要,則默認為1),返回一個Iterator,常用于循環中,如for(var i in range(1,5)) {print(i)},將依次打印1234. - **flush** 強制io輸出。 - **json**,將對象轉成json字符串,如 var data = json(userList) 可以跟一個序列化規則 如,var data = json(userList,"[*].id:i"),具體參考?[https://git.oschina.net/xiandafu/beetl-json](https://git.oschina.net/xiandafu/beetl-json) - **pageCtx** ,僅僅在web開發中,設置一個變量,然后可以在頁面渲染過程中,調用此api獲取,如pageCtx("title","用戶添加頁面"),在其后任何地方,可以pageCtx("title") 獲取該變量 - **type.new** 創建一個對象實例,如 var user = type.new("com.xx.User"); 如果配置了IMPORT_PACKAGE,則可以省略包名,type.new("User") - **type.name** 返回一個實例的名字,var userClassName = type.name(user),返回"User" - **global** 返回一個全局變量值,參數是一個字符串,如 var user = global("user_"+i); - **cookie** 返回指定的cookie對象 ,如var userCook = cookie("user"),allCookies = cookie(); ### 4.1.2 字符串相關方法 > strutil方法對參數均不做空指針檢測,你可自定義方法來覆蓋這些內置的方法 - **strutil.startWith** ${ strutil.startWith("hello","he")} 輸出是true - **strutil.endWith** ${ strutil.endWith("hello","o")} 輸出是true - **strutil.length** ${ strutil. length ("hello")},輸出是5 - **strutil.subString** ${ strutil.subString ("hello",1)},輸出是"ello" - strutil.subStringTo ${ strutil.subStringTo ("hello",1,2)},輸出是"e" - **strutil.split** ${ strutil.split ("hello,joeli",",")},參數第一個是字符串,第二個是正則表達式。輸出是數組:返回第一個是"hello",第二個是"joelli" - strutil.contain ${ strutil.contain ("hello,"el")},輸出是true - **strutil.toUpperCase** ${ strutil.toUpperCase ("hello")},輸出是HELLO - **strutil.toLowerCase** ${ strutil.toLowerCase ("hello")},輸出是hello - **strutil.replace** ${ strutil.replace ("hello","lo","loooo")},輸出是helloooo - strutil.format ${ strutil.format ("hello,{0}, my age is {1}","joeli",15)},輸出是hello,joeli, my age is 15. 具體請參考[http://docs.oracle.com/javase/6/docs/api/java/text/MessageFormat.html](http://docs.oracle.com/javase/6/docs/api/java/text/MessageFormat.html) - **strutil.trim** 去掉字符串的尾部空格 - **strutil.formatDate** var a = strutil.formatDate(user.bir,'yyyy-MM-dd')}; - **strutil.index** var index = strutil.index("abc","a");返回 索引0 - **strutil.lastIndex** var index = strutil.lastIndex("aba","a");返回索引2 ### 4.1.3 數組相關方法 - **array.range** 返回數組或者Collection一部分,接受三個參數,第一個是數組或者Collection子類,第二,三個參數分別是起始位置 - **array.remove** 刪除某個數組或者Collection的一個元素,并返回該數組或者Collection.第一個是數組或者Collection子類,第二個參數是元素 - **array.add** 向數組或者Collection添加一個元素,并返回該數組或者Collection。第一個是數組或者Collection子類,第二個參數是元素 - array.contain 判斷數組或者元素是否包含元素,如果包含,返回true。否則false。第一個是數組或者Collection子類,第二個參數是元素 - **array.toArray** 轉化成數組,如array.toArray(1,2,"a"); - **array.collection2Array** 將java集合轉化為數組 array.collection2Array([1,2,'']) ### 4.1.4 正則表達式相關方法 - **reg.match(str,regex)** str為需要處理的字符串,regex是表達式 - **reg.replace(str,regex,replace)**,str為需要處理的字符串,regex是表達式,替換的字符串替換字符串 - **reg.find(str,regex)** 返回找到的符合表達式的第一個字符串,否則返回空字符串 - **reg.findList(str,regex)** 找到所有符合表達式的字符串,否則返回空列表 - **reg.split(str,regex)**,對字符串進行切分,返回列表 - **reg.split(str,regex,limit)** 同上,limit是最多返回個數
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看