SSI 参考 - 2。

EchoCommand
The echo SSI command. As extensions, it has the parameters "reqstate" (for echoing Jigsaw request states) and "reqheader" (for echoing request header).Also, it can take the flag "here", whose presence means that the variable is to be interpreted at the deepest request level (in the case of chained internal requests), instead of doing so at the top (external request) level. It inserts the value of a variable in the document.
Parameters:
  • var = a SSI variable
  • reqstate = a Jigsaw request state
  • reqheader = a request header
  • here = a flag
Examples:
<!--#echo var="DOCUMENT_URI" --> display the document uri <!--#echo reqheader="referer" --> display the referer header of the request <!--#echo reqstate="pathinfo" --> display the request state "pahtinfo" 
ExecCommand
the SSI exec command. It inserts the output from a CGI script or a shell command in the document. Note that in the Jigsaw architecture CGI scripts are just another resource class, so that no distinction is made between executing a CGI script or including a file.
Parameters:
  • cmd = the command to execute
Example:
<!--#exec cmd="ls -lsa" --> display the result of the ls command 
FLastModCommand
The standard lastmod SSI command.
Parameters: none
Example:
<!--#flastmod--> 
FSizeCommand
The SSI fsize command. It inserts the size of the unparsed file in the document, according to the current value of the variable sizefmt.See configCommand.
Parameters: none
Example:
<!--#fsize --> 
IncludeCommand
The SSI include command. (CGI scripts can be included, simply by providing a so-called virtual path to a resource with a CgiFrame).
Parameters:
  • file = the file to include
  • virtual = a virtual path
  • ifheader = a request header
  • else = a file
Examples:
<!--#include file="included.html" --> include the file "included.html" in the current file <!--#include ifheader="Referer" file="included.html" else="included2.html" --> if the request has a Referer header then include "included.html" else include "included2.html" 
jdbcCommand
The SSI jdbc command allows you to query a SQL database via JDBC. Combinated with some Control Commands, it allows you to display the content of a database easyly.
Parameters:
  • select = the SQL request
  • url = the database URL
  • driver = the JDBC driver class
  • user = the username
  • password = the password
  • name = the result name
  • column = the column number
  • next = a flag
Example:
<!--#jdbc select="SELECT * FROM services" name="result" driver="com.imaginary.sql.msql.MsqlDriver" url="jdbc:msql://www43.inria.fr:4333/services" --> this is the setup of the command. <!--#jdbc name="result" next="true" --> this command move the pointer to the next line of the result set. <!--#jdbc name="result" column="1" --> display the first column of the current line. <!--#jdbc name="result" column="2" --> display the second column of the current line. <!--#jdbc name="result" column="3" --> display the third column of the current line. 
ServletCommand
The SSI servlet command. Servlet can be executed simply by providing a url path to a servlet class.
Parameters:
  • name = the command identifier
  • code = the servlet URL
  • param = a parameter name
  • value = a parameter value
Example:
 <!--#servlet name="Snoop" param="p1" value="v1" --> <!--#servlet name="Snoop" param="p2" value="v2" --> <!--#servlet name="Snoop" param="p3" value="v3" --> <!--#servlet name="Snoop" code="/servlet/snoop" --> 

Control Commands

CounterCommand
The SSI counter command. Used to do things like cpt = cpt + 1.
Parameters:
  • name = the counter identifier
  • init = the init value
  • incr = the value to add to the counter
  • value = a flag
Example:
<!--#cpt name="cpt1" init="0" --> Initialisation: cpt1 = 0 <!--#cpt name="cpt1" incr="1" --> cpt1 = cpt1 + 1 <!--#cpt name="cpt1" value="true" --> display the current value of cpt1 
ElseCommand
Parameters:
  • name = the if command identifier
Example:
<!--#else name="if2" --> 
EndifCommand
Parameters:
  • name = the if command identifier
Example:
<!--#endif name="if2" --> 
EndloopCommand
Parameters:
  • name = the loop command identifier
Example:
<!--#endloop name="loop2" --> 
ExitloopCommand
Parameters:
  • name = the loop command identifier
  • command = a command name (jdbs, cpt)
  • var = a command identifier
  • equals = a string value
Example:
<!--#exitloop name="loop2" command="cpt" var="cpt1" equals="4" --> 
IfCommand
Parameters:
  • name = the command identifier
  • command = a command name (jdbc, cpt)
  • var = a command identifier
  • equals = a string value
Example:
<!--#if name="if2" command="cpt" var="cpt1" equals="2" --> 
LoopCommand
Parameters:
  • name = the command identifier
Example:
<!--#loop name="loop2" --> 

Example

The following example, display the four first columns of the three first lines of the users database.
 <!--#jdbc name="result2" select="SELECT * FROM users" user="bmahe" password="" url="jdbc:msql://www43.inria.fr:4333/users" driver="com.imaginary.sql.msql.MsqlDriver" --> <table border=2> <!--#cpt name="cpt1" init="0" --> <tr><td><b>Name </td><td><b>Login</td> <td><b>Email</td><td><b>Age </td></tr> <!--#loop name="loop2" --> <!--#jdbc name="result2" next="true" --> <tr> <td> <!--#jdbc name="result2" column="1" --> </td><td> <!--#jdbc name="result2" column="2" --> </td><td> <!--#jdbc name="result2" column="3" --> </td><td> <!--#jdbc name="result2" column="4" --> </td> </tr> <!--#cpt name="cpt1" incr="1" --> <!--#exitloop name="loop2" command="cpt" var="cpt1" equals="3" --> <!--#endloop name="loop2" --> </table> counter value : <!--#cpt name="cpt1" value="true" --> 

The result could be:

NameLoginEmailAge
Smith ssmith ssmith@example.org 25
lafrim ylafrim lafrim@example.org 25
Teole pteole teole@example.org 27
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值