執行個體:實現動態網頁的靜態緩衝,動態網頁靜態

來源:互聯網
上載者:User

執行個體:實現動態網頁的靜態緩衝,動態網頁靜態

一行代碼實現緩衝的臨時檔案儲存,四行代碼實現緩衝判斷,三行代碼實現臨時檔案調用

源動態網頁

<title>執行個體:實現動態網頁的靜態緩衝</title><h3>執行個體:實現動態網頁的靜態緩衝</h3><p><chtml><for end=0 start=20>    <b>@{int:@{for:getSuffix}+1}-</b>    <forend=@{for:getSuffix}>        <fontcolor=red>@{int:@{for:getSuffix}+1}-</font>    </for>    <br></for></chtml></p>

(例子檔案:_samples/file_page.html) 

讀緩衝的靜態檔案資訊

<file act=info>WEB-INF/cache/page_test.html</file>

判斷靜態檔案是否存在

<if x="@{file:exists}"else=0>    <call>page</call>    <callx=true>cache</call></if>

存在就調用cache,不存在則調用page

   <call>page</call>    <call x=true>cache</call>

可調用標籤cache,讀快取檔案

<chtml onlycallid=cache><file act=read method=str name=page>WEB-INF/cache/page_test.html</file></chtml>

可調用標籤page

<chtml id=page file="@{sys:curPath}file_page.html" save="WEB-INF/cache/page_test.html" onlycall />

引入動態網頁檔案@{sys:curPath}file_page.html,並儲存為WEB-INF/cache/page_test.html檔案

顯示緩衝內容

@{file:page}

完整代碼 

<html><chtml><file act=info>WEB-INF/cache/page_test.html</file><if x="@{file:exists}" else=0><call>page</call><call x=true>cache</call></if></chtml><chtml id=page file="@{sys:curPath}file_page.html" save="WEB-INF/cache/page_test.html" onlycall /><chtml onlycall id=cache><file act=read method=str name=page>WEB-INF/cache/page_test.html</file></chtml>@{file:page}</html>

效果


(例子檔案:_samples/file_cache.html)

抓緊體驗體驗吧!

輕開平台資源下載及說明

平台及最新開發手冊免費下載:http://download.csdn.net/detail/tx18/8464425

開發執行個體:輕開B2C電子商務網站,免費下載:http://download.csdn.net/detail/tx18/8318585

輕開平台會不定期升級為大家提供更多強大而Easy的功能,請留意最新的開發手冊

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.