閱讀76 返回首頁    go 技術社區[雲棲]


在SHTML中通過SSI指令實現文件動態包含

文章地址: https://blog.csdn.net/5iasp/article/details/12992769

作者: javaboy2012
Email:yanek@163.com
qq:    1046011462

 

在SHTML中通過SSI指令實現文件動態包含

代碼如下:

測試代碼:

假設文件為index.shtml 內容如下:

<!--#if expr="$QUERY_STRING='id=1'" --> 
<!--#include virtual="/test/1.inc" -->
<!--#endif --> 

<!--#if expr="$QUERY_STRING='id=2'" --> 
<!--#include virtual="/test/2.inc" -->
<!--#endif --> 


<!--#if expr="$QUERY_STRING=''" --> 
<!--#include virtual="/test/3.inc" -->
<!--#endif --> 


 

有如下三個被包含的文件。

https://www.myweb.com/test/1.inc
https://www.myweb.com/test/2.inc
https://www.myweb.com/test/3.inc

index.shtml的發布路徑:

https://www.myweb.com/index.shtml

https://www.myweb.com/test/index.shtml?id=2  則執行後顯示包含2.inc的內容
https://www.myweb.com/test/index.shtml?id=1  則執行後顯示包含1.inc的內容
https://www.myweb.com/test/index.shtml       則執行後顯示包含3.inc的內容


通過如上處理則可以實現實現在服務器端實現動態包含。

在apache服務器下測試通過。

 

參考資料: https://apache.jz123.cn/howto/ssi.html

ssi參考文檔 : https://download.csdn.net/detail/5iasp/6445779

 

 

最後更新:2017-04-03 14:53:52

  上一篇:go Mybatis中javaType和jdbcType對應和CRUD例子
  下一篇:go 如何遠程登錄ubuntu