URLReferer在wap(wml)开发中的应用

来源:互联网 发布:自动化编程 编辑:程序博客网 时间:2024/06/04 18:04

我们在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|论坛">
<align="left">
欢迎:
<href="usercp.aspx"> 虫虫</a>
 
<href="usercpshowpm.aspx">信(1)</a> 
<href="logout.aspx?userkey=e63e600a">退出</a><br/> 
<href="index.aspx">Discuz!NT</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&amp;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/>
 
<href="index.aspx">返回论坛首页</a><br/>
 报时:17:41:05
<br/>
 ET:0.01
<br/>
 nt!discuz wap beta1 by xyzn.net
</p>
</card>
</wml>
原创粉丝点击