webx中怎么跳转页面跳转url不变与url显示不一样

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
您的访问请求被拒绝 403 Forbidden - ITeye技术社区
您的访问请求被拒绝
亲爱的会员,您的IP地址所在网段被ITeye拒绝服务,这可能是以下两种情况导致:
一、您所在的网段内有网络爬虫大量抓取ITeye网页,为保证其他人流畅的访问ITeye,该网段被ITeye拒绝
二、您通过某个代理服务器访问ITeye网站,该代理服务器被网络爬虫利用,大量抓取ITeye网页
请您点击按钮解除封锁&WebX的url生成及URIBroker的问题和解析
将WebX应用部署在“/”上,新建一个component名为“happy”。
其中的happy对应的uri对象配置如下:
&uris:uri id="server" requestAware="true" /&
&!-- happy --&
&uris:turbine-uri id="happyModule" exposed="true" extends="server"&
&componentPath&/happy&/componentPath&
&/uris:turbine-uri&
&uris:turbine-content-uri id="happyContent" exposed="true" extends="happyModule" /&
诡异的现象
当我们分别打开“http://127.0.0.1:8081/happy/”、“http://127.0.0.1:8081/happy/index”和“http://127.0.0.1:8081/happy/index”时,我们发现:
在“http://127.0.0.1:8081/happy/”中,$happyModule和$happyContent都被解析为“http://127.0.0.1:8081/happy/happy”,显然,这不是我们想要的结果。
在“http://127.0.0.1:8081/happy/index”中, $happyModule和$happyContent都被解析为“http://127.0.0.1:8081/happy/index/happy”,这,跟我们想要的相差更多了
在“http://127.0.0.1:8081/happy/index.htm”中, $happyModule和$happyContent都被解析为“http://127.0.0.1:8081/happy”,后面少了个“/”,嗯,还凑合。
我们先来看一下,为啥上面的若干情况如此诡异呢?考虑以下四个URL:
http://127.0.0.1:8081/happy
http://127.0.0.1:8081/happy/
http://127.0.0.1:8081/happy/index
http://127.0.0.1:8081/happy/index.htm
其实,他们指向的component都是happy,对应的screen都是index。而事实上,WebX也是这么映射到对应的screen的——因为我们能够正常访问页面,而且都是happy下index的内容,对吧。理论上,我们要求WebX对确定的映射内容也返回稳定的渲染结果,而事实却并非如此。为什么呢?我们要深入源代码一探究竟。
先简单介绍一下,在com.alibaba.citrus.service.uribroker.uri.URIBroker类中,有一个叫path的数组,里面存放了杠与杠之间的各部分。比如/aaa/bbb/ccc/,那么这个数组存放的是[aaa, bbb, ccc]。此类还有一个叫renderPath()的函数,作用是把path中的各个元素组合起来。如上面的数组会组合成“/aaa/bbb/ccc”。看起来不错,不过少了最后的一道杠。
回到上面的例子,为什么会出现了两次“happy”呢?直接原因,是path数组中存了两个“happy”。根本原因,是因为request.getServletPath()返回了“/happy/”,导致ServletURIBroker类中populateWithRequest()函数误以为当前的servlet是happy。因为在j2ee中,后面处理URI时会把servlet部分切割掉,所以多加了一次“happy”。这是不正确的,因为当前的servlet应该是“/”才对!
而这个getServletPath()函数,则是com.alibaba.citrus.service.requestcontext.rewrite.impl.RewriteRequestContextImpl#RequestWrapper中定义的。
论坛已经有人提出相关的问题:http://www.openwebx.org/forum/showthread.php?tid=91&highlight=servletpath。两年过去,仍旧如故。
相当于写死了URL(参见http://openwebx.org/forum/showthread.php?tid=478和/epplera/item/5877681cce410e)。
使用turbine-content-uri,并且增加:&contextPath&Web App的部署目录,一般部署在根目录则填“/”&/contextPath&
&uris:uri id="server" requestAware="false"&
&serverName&127.0.0.1&/serverName&
&serverPort&8081&/serverPort&
&/uris:uri&
还凑合的一道杠
为什么说“http://127.0.0.1:8081/happy”还凑合呢?因为,Spring框架中,当我们直接访问“http://127.0.0.1:8081/happy”时,Web服务器发现该网址不存在,于是就返回302跳转到“http://127.0.0.1:8081/happy/”去,所以最后那个是可以正常访问的,虽然跟我们想要的还是差了一道杠(差了网址结尾的“/”)。
不过,一道杠的差别,却不是轻易就能够解决的。话分两头:一方面,想要用turbine-uri在后面加一道简简单单的杠,几乎是不可能的,后文详述原因;另一方面,如果turbine-uri是指向python编写的web app(尤其是用强哥框架,英文名Django框架)的话,就不一定会自动给你补上后面的一道杠,而是冷冰冰地返回一个404错误。
一道杠的距离
这时候,再说一下,WebX中,如果要在uri后面加一道杠,究竟有多难?答案是很难。假设我们分别要生成“http://blog.creke.net/tag/linux/”和“http://blog.creke.net/803.html”,注意后面有道杠。看看下面的配置:
&uris:uri id="crekeServer" requestAware="false" &
&serverName&blog.creke.net&/serverName&
&/uris:uri&
&uris:turbine-content-uri id="crekeLink1" exposed="true" extends="crekeServer" &
&contentPath&/tag/linux/&/contentPath&
&/uris:turbine-content-uri&
&uris:turbine-content-uri id="crekeLink2" exposed="true" extends="crekeServer" &
&componentPath&/tag&/componentPath&
&contentPath&/linux/&/contentPath&
&/uris:turbine-content-uri&
&uris:turbine-uri id="crekeLink3" exposed="true" extends="crekeServer" &
&target&/tag/linux/&/target&
&/uris:turbine-uri&
&uris:turbine-content-uri id="crekeLink4" exposed="true" extends="crekeServer" &
&contentPath&/803.html&/contentPath&
&/uris:turbine-content-uri&
生成的结果分别是:
http://blog.creke.net/tag/linux
http://blog.creke.net/tag/linux
http://blog.creke.net/tag/linux
http://blog.creke.net/803.html
根本原因是,uriBroker将任何URL的路径部分都一视同仁地分解为上文所述的path数组。这对于有后缀名的“http://blog.creke.net/803.html”来说无所谓,反正“803.html”是path的一个元素,直接加就对了;但是对于“http://blog.creke.net/tag/linux/”来说,uriBroker并不会记录是否需要补上最后的一道杠,也就是被吞掉了。
在WebX中,如果不想在配置中写死URL前缀,那么除了首页外,总是要加上index.htm来标示默认页面。而如果要生成最后带“/”的URL的字符串,则不要使用URIBroker类。
最后,还是用WebX文档中的一句话来作总结吧:“我并不是说所有的框架都一样好,而是说只要假以时日,所有的框架在发展过程中,必然会积聚好的方面,淘汰坏的方面,从而变得足够好。从这个角度看,的确没有特别明显的理由来选择Webx,但也没有明显的理由不选择Webx。”(via http://openwebx.org/docs/preface.html#d0e76)
Michael Zhou authored 6 months ago
git上最后一次提交是6个月以前...我比较看重可持续性
Creke Blog | 梦溪博客.
Js O4 noire theme by Jinwen, valid
Stats: 43 queries. 0.241 seconds. |js 控制页面跳转的5种方法
字体:[ ] 类型:转载 时间:
这篇文章介绍了js 控制页面跳转的5种方法,有需要的朋友可以参考一下
第一种: 代码如下:&&& &script language="javascript" type="text/javascript"&&&&&&&&&&& window.location.href="login.jsp?backurl="+window.location. &&& &/script&第二种: 代码如下:&&& &script language="javascript"&alert("返回");window.history.back(-1);&& &/script&第三种: 代码如下:&& &script language="javascript"&window.navigate("top.jsp");& &/script&第四种: 代码如下:&& &script language="JavaScript"&&&&&&&&&& self.location='top.htm';&& &/script&第五种: 代码如下:&& &script language="javascript"&&&&&&&&&& alert("非法访问!");&&&&&&&&& top.location='xx.jsp';&& &/script&
隔多少秒后自动跳转到其它页(js脚本)
在&head&&/head&之间加入js
代码如下:&script language="javascript"&var secs = 3; //倒计时的秒数 var URL ;function Load(url){URL =for(var i=i&=0;i--) { && window.setTimeout('doUpdate(' + i + ')', (secs-i) * 1000); } }function doUpdate(num) { document.getElementById('ShowDiv').innerHTML = '将在'+num+'秒后自动跳转到主页' ;if(num == 0) { window.location = URL; }}&/script&
然后在&body&里面加上&body onload="Load('index.asp')"&&& index.asp为自己要跳转的页面。
在&body&&/body&之间加上&div id="ShowDiv"&&/div&
代码如下:&p style="text-indent: 2 margin-top: 30"&系统将在 &span id="time"&5&/span& 秒钟后自动跳转至新网址,如果未能跳转,&a href="http://www.jb51.net" title="点击访问"&请点击&/a&。&/p&&script type="text/javascript"& &&&& delayURL();&&& &&& function delayURL() { &&&&&&& var delay = document.getElementById("time").innerHTML;&var t = setTimeout("delayURL()", 1000);&&&&&&& if (delay & 0) {&&&&&&&&&&& delay--;&&&&&&&&&&& document.getElementById("time").innerHTML =&&&&&&& } else {&&&& clearTimeout(t);&&&&&&&&&&&& window.location.href = "http://www.jb51.net";&&&&&&& }&&&&&&& &&& } &/script&
您可能感兴趣的文章:
大家感兴趣的内容
12345678910
最近更新的内容
常用在线小工具温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!&&|&&
杭州阿里巴巴-朝9晚9
LOFTER精选
网易考拉推荐
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
阅读(2072)|
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
历史上的今天
在LOFTER的更多文章
loftPermalink:'',
id:'fks_085064',
blogTitle:'Webx框架之服务简介(2)----URL生成篇',
blogAbstract:'4.URIBroker的种类和配置4.1.URIBrokerURIBroker定义了一个标准的URL中的所有部件:http&& &://&& &user&& &:&& &pass&& &@&& &&& &:&& &8080&& &/view&& &?&& &id=1&& &#&& &top&& &│&& &&& &│&& &&& &│&& &&& &│&& &&& &│&&',
blogTag:'webx',
blogUrl:'blog/static/',
isPublished:1,
istop:false,
modifyTime:0,
publishTime:4,
permalink:'blog/static/',
commentCount:0,
mainCommentCount:0,
recommendCount:0,
bsrk:-100,
publisherId:0,
recomBlogHome:false,
currentRecomBlog:false,
attachmentsFileIds:[],
groupInfo:{},
friendstatus:'none',
followstatus:'unFollow',
pubSucc:'',
visitorProvince:'',
visitorCity:'',
visitorNewUser:false,
postAddInfo:{},
mset:'000',
remindgoodnightblog:false,
isBlackVisitor:false,
isShowYodaoAd:false,
hostIntro:'杭州阿里巴巴-朝9晚9',
hmcon:'1',
selfRecomBlogCount:'0',
lofter_single:''
{list a as x}
{if x.moveFrom=='wap'}
{elseif x.moveFrom=='iphone'}
{elseif x.moveFrom=='android'}
{elseif x.moveFrom=='mobile'}
${a.selfIntro|escape}{if great260}${suplement}{/if}
{list a as x}
推荐过这篇日志的人:
{list a as x}
{if !!b&&b.length>0}
他们还推荐了:
{list b as y}
转载记录:
{list d as x}
{list a as x}
{list a as x}
{list a as x}
{list a as x}
{if x_index>4}{break}{/if}
${fn2(x.publishTime,'yyyy-MM-dd HH:mm:ss')}
{list a as x}
{if !!(blogDetail.preBlogPermalink)}
{if !!(blogDetail.nextBlogPermalink)}
{list a as x}
{if defined('newslist')&&newslist.length>0}
{list newslist as x}
{if x_index>7}{break}{/if}
{list a as x}
{var first_option =}
{list x.voteDetailList as voteToOption}
{if voteToOption==1}
{if first_option==false},{/if}&&“${b[voteToOption_index]}”&&
{if (x.role!="-1") },“我是${c[x.role]}”&&{/if}
&&&&&&&&${fn1(x.voteTime)}
{if x.userName==''}{/if}
网易公司版权所有&&
{list x.l as y}
{if defined('wl')}
{list wl as x}{/list}如何获取跳转前页面的url
[问题点数:100分,结帖人pig_2000]
如何获取跳转前页面的url
[问题点数:100分,结帖人pig_2000]
不显示删除回复
显示所有回复
显示星级回复
显示得分回复
只显示楼主
2010年7月 扩充话题大版内专家分月排行榜第三
本帖子已过去太久远了,不再提供回复功能。

我要回帖

更多关于 改变页面url 但不跳转 的文章

 

随机推荐