[英]Unable to find or serve resource, /Directory1/Myproject/index.xhtml
I have a log-out function that implements logout of the user currently in session. 我有一个注销功能,用于实现会话中当前用户的注销。 This function can be called from many different pages located to various directories in my project. 可以从位于项目中各个目录的许多不同页面调用此函数。 I want , after the function is called , the user to be redirected to the index page. 我想要在函数调用之后将用户重定向到索引页面。 But I cannot achieve this. 但是我无法做到这一点。 I know that redirection depends on the return string of the function, but it seems that this string is referring to the current directory. 我知道重定向取决于函数的返回字符串,但似乎此字符串引用的是当前目录。
Eg 例如
Myproject
-index.xhtml
--Directory1
---page1.xhtml (this page is located in the Directory1-subdirectory of Myproject)
The function is this: 函数是这样的:
String logout(){
..
return "Myproject/index.xhtml"
}
which works fine as long as it is called from the index.xhtml 只要从index.xhtml调用它就可以正常工作
whereas when I call it from the page1.xhtml it doens't work with message: 而当我从page1.xhtml调用它时,它不支持消息:
Unable to find or serve resource, /Directory1/Myproject/index.xhtml. 无法找到或提供资源/Directory1/Myproject/index.xhtml。
is there any way to make this work or should I go for another way? 有什么方法可以使这项工作奏效,还是我应该另辟way径?
尝试添加'/'
String logout(){ .. return "/Myproject/index.xhtml" }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.