重定向显示错误“无法创建页面”

时间:2013-04-29 10:35:56

标签: redirect xpages

我有一个小的xpage,其中包含一个带有以下点击事件的按钮:

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

只要点击按钮,我就会发出以下错误消息:

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 个答案:

答案 0 :(得分:2)

尝试删除redirectToPage的第二个参数或将其设置为false,以更改true的代码。这应该有效:

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

或者你可以这样写:

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

当您将第二个参数设置为false时,重定向会发生在服务器上,因此您必须编写类似这样的内容才能使其正常工作(假设viewAllDocuments.xsp位于同一个数据库中):

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

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

有关详细信息,请参阅documentation of redirectToPagethis article by Mark Leusink

答案 1 :(得分:2)

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

将第二个参数设置为true,新网址会附加到您当前的网址:如果您当前在

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

然后将网址解析为

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

至少那是我的测试服务器(8.5.3)上的测试数据库中发生的情况。不知道是否有办法防止这种情况发生;我通常使用链接控件(如果它看起来像一个按钮,没问题:插入一个看起来像按钮的图像),或者我使用客户端脚本,如

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