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

我们在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 >
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值