2013-04-29 76 views
0

我得到了含有与Click事件中的一个按钮小的XPage:重定向显示了错误“无法创建页面”

context.redirectToPage("http://server:8080/AWM.nsf/viewAllDocuments.xsp", false); 

当我按一下按钮我geht以下错误消息:

Error while executing JavaScript action expression Script interpreter error, line=1, col=9: [TypeError] Exception occurred calling method XSPContext.redirectToPage(string, boolean) 
com.ibm.xsp.page.PageNotFoundException: Could not create the page /http://server:8080/AWM.nsf/viewAllDocuments.xsp because the class xsp.http_003a._002fserver_003a8080.awm.nsf.ViewAllDocuments could not 
be found. Please check your spelling. 
com.ibm.xsp.page.PageNotFoundException: Could not create the page /http://server:8080/AWM.nsf/viewAllDocuments.xsp because the class xsp.http_003a._002fserver_003a8080.awm.nsf.ViewAllDocuments could not 
be found. Please check your spelling. Could not create the page /http://server.de:8080/AWM.nsf/viewAllDocuments.xsp because the class 
xsp.http_003a._002fserver_003a8080.awm.nsf.ViewAllDocuments could not be found. Please check your spelling. Cannot find class xsp.http_003a._002fserver_003a8080.awm.nsf.ViewAllDocuments in NSF 

我试图重建数据库并做了一个干净的,但没有改变。 xpage viewAllDocuments.xsp存在,如果我复制错误消息的路径并尝试直接打开该页面,那么工作。

有人可以在这里给我提示吗?

回答

2

尝试通过删除第二个参数false或将其设置为true来更改redirectToPage的代码。这应该工作:

context.redirectToPage("http://server:8080/AWM.nsf/viewAllDocuments.xsp") 

或者你可以写这样的事情:当您设置的第二个参数false重定向发生在服务器

facesContext.getExternalContext().redirect("http://server:8080/AWM.nsf/viewAllDocuments.xsp") 

,所以你会写这样的事情,使它的工作(假定viewAllDocuments.xsp是在同一个数据库):

context.redirectToPage("viewAllDocuments.xsp", false) 

当重定向发生在服务器上浏览器的网址将不会更新,但页面会。

有关更多信息,请参阅documentation of redirectToPagethis article by Mark Leusink

+0

这就是它!使用没有第二个参数的同样的重定向工作! – 2013-04-29 12:08:32

2

将第二个参数设置为false,就像您所做的那样,显然会尝试将您的新URL解释为相对于当前URL的资源(因此错误提及“/http:// ...”)。

设置第二个参数去真正的新的URL被附加到当前网址:如果您目前正处于

http://myserver/mydb.nsf/mypage.xsp 

那么该URL解析为

http://myserver/mydb.nsf/http://newserver/newpath.html.xsp 

至少,这是发生了什么在我的测试服务器上的测试数据库(8.5.3)中。不知道是否有办法阻止这一点;我通常去任何一个链路控制(如果它看起来像一个按钮,没有任何问题:插入图像看起来像一个按钮),或我使用客户端脚本在

location.href="http://newserver/newresource" 
+0

谢谢!这给了我正确的提示! – 2013-04-29 12:09:25