我们在web开发中,经常使用到request集合中的一个元素URLReferer,这个属性是记录当前请求的父请求地址(即记录哪一个地址使得用户点击了链接)。我们通常用于鉴别请求来路、防止盗链等。
而在wml 1.1中,你无法轻松获得,必须使用<go>标签里面的属性 sendreferer
请看摘自wap文档的sendreferer 说明
sendreferer=boolean If this attribute is true, the user agent must specify, for the server's benefit, the URI of the deck containing this task (i.e., the referring deck). This allows a server to perform a form of access control on URIs, based on which decks are linking to them. The URI must be the smallest relative URI possible if it can be relative at all. For example, if sendreferer=true, an HTTP based user agent shall indicate the URI of the current deck in the HTTP "Referer" request header [RFC2616]. method=(post|get) This attribute specifies the HTTP submission method. Currently, the values of get and post are accepted and cause the user agent to perform an HTTP GET or POST respectively.
这是一个完整的使用例子
<?xml version="1.0" encoding="utf-8"?><!DOCTYPE wml PUBLIC "-//wapFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>
<head>
<meta http-equiv="Cache-Control" content="max-age=0"/>
</head>
<card id="main" title="ASP.net|论坛">
<p align="left">
欢迎:<a href="usercp.aspx"> 虫虫</a>
<a href="usercpshowpm.aspx">信(1)</a>
<a href="logout.aspx?userkey=e63e600a">退出</a><br/>
<a href="index.aspx">Discuz!NT</a> > <a href="showforum.aspx?forumid=19">S60第一第二版专区</a> > 发表新主题<br/>
<anchor title="back"><prev/>后退</anchor><br/>
用户名:虫虫<br/>
标题:<input name="title"/><br/>
内容:<input name="message"/><br/>
<img src="/tools/VerifyImagePage.aspx?bgcolor=F5FAFE&time=0.812"/><br/>
验证码:<input name="vcode" /><br/>
<anchor>提交
<go href="posttopic.aspx" method="post" sendreferer="true">
<postfield name="title" value="$(title)"/>
<postfield name="message" value="$(message)"/>
<postfield name="forumid" value="19"/>
<postfield name="vcode" value="$(vcode)" />
</go>
</anchor><br/> <br/>
<a href="index.aspx">返回论坛首页</a><br/>
报时:17:41:05<br/>
ET:0.01<br/>
nt!discuz wap beta1 by xyzn.net
</p>
</card>
</wml>
本文介绍在WML1.1标准中如何使用<go>标签内的sendreferer属性来发送引用页面的URI。这对于服务器实现基于来源页面的访问控制非常重要。
2万+

被折叠的 条评论
为什么被折叠?



