我不知道为什么这段代码不能正确地将我重定向到我想要的html页面。这是我正在使用的代码:
String url = "Start.xhtml";
FacesContext fc = FacesContext.getCurrentInstance();
ExternalContext ec = fc.getExternalContext();
try {
ec.redirect(url);
}catch (IOException ex) {
ex.printStackTrace();
}
它似乎正在重定向页面,但是什么也没有出现,即使我在html文件中有东西。我该如何放置xhtml文件的字符串?
感谢您的帮助
您必须考虑应用程序的上下文根。在大多数情况下,它是这样的:
String url = "/ApplicationName/faces/Start.jsf";
try {
FacesContext.getCurrentInstance().getExternalContext.redirect(url);
} catch (IOException e) {
// error handling
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句