Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jsf 添加omnifaces项目在重定向时提供了错误的url_Jsf_Primefaces_Glassfish_Omnifaces - Fatal编程技术网

Jsf 添加omnifaces项目在重定向时提供了错误的url

Jsf 添加omnifaces项目在重定向时提供了错误的url,jsf,primefaces,glassfish,omnifaces,Jsf,Primefaces,Glassfish,Omnifaces,在jsf项目中使用omnifaces 1.6,在glassfish 3.1.2上使用primefaces 3.5 FacesContext.getCurrentInstance().getExternalContext().redirect("localhost/my-project/views/index.jsf"); 使用此代码将重定向到url为localhost/my project/ 这个问题是当添加了omnifaces而没有omnifaces时,函数可以正常工作,没有问题我不知道

在jsf项目中使用omnifaces 1.6,在glassfish 3.1.2上使用primefaces 3.5

FacesContext.getCurrentInstance().getExternalContext().redirect("localhost/my-project/views/index.jsf");  
使用此代码将重定向到url为
localhost/my project/


这个问题是当添加了omnifaces而没有omnifaces时,函数可以正常工作,没有问题

我不知道您期望的是什么,但是当您重定向到
localhost/my project/
时,重定向到带有url
localhost/my project/
的页面似乎是正确的行为

可能您错过了该端口(例如重定向到
localhost:8080/my project/
),但通常情况下,它不打算重定向到包含localhost的URL,而是重定向到特定页面(例如重定向到
index.jsf
index.xhtml
)。您甚至不需要webapp上下文(即
myproject
),只需重定向到“主页”,如下所示:

FacesContext.getCurrentInstance().getExternalContext().redirect("home.xhtml");

这不是默认行为。您是否在
web.xml
faces config.xml
中更改了任何内容?也许与FacesView有关?在我的web.xml中,我使用的是auth方法表单,当打开index.jsf时,会打开一个指向登录页面的重定向,在index.jsf页面的preRenderView中,我调用这行代码
FacesContext.getCurrentInstance().getExternalContext().redirect(“localhost/my project/views/index.jsf”)它将我重定向到localhost/my project/而不是index.jsf,在这里重定向url是正确的,一个战争风格的SSCCE会很有帮助。我至少可以说,给定的重定向URL首先确实很奇怪,正如unwichtich的答案所示。可能很奇怪,但是如果没有omniface jar文件,重定向是正确的,同时添加jar文件,重定向更改如所示,我无法回答这个问题,直到我看到SSCCE带有战争的味道。