Java 使用primefaces、spring创建指向另一个页面的重定向链接

Java 使用primefaces、spring创建指向另一个页面的重定向链接,java,spring,primefaces,Java,Spring,Primefaces,我想使用primefaces创建指向另一个页面的重定向链接,spring: if (true condition) { //redirect to page } else { //keep the current page //open dialog } 谢谢。试试这个 if( true condition ) { HttpServletResponse response = (HttpServletResponse) FacesContext.getCu

我想使用primefaces创建指向另一个页面的重定向链接,spring:

if (true condition) {
     //redirect to page
} else {
     //keep the current page
     //open dialog
}
谢谢。

试试这个

if( true condition ) {
    HttpServletResponse response = (HttpServletResponse) FacesContext.getCurrentInstance().getExternalContext().getResponse();
    response.sendRedirect("www.google.pl");
}

您使用的是spring mvc控制器?
if (condition is true) {
    ExternalContext externalContext = FacesContext.getCurrentInstance().getExternalContext();
    externalContext.redirect("other-page.xhtml");
}
else {
    RequestContext context = RequestContext.getCurrentInstance();
    context.execute("myDialog.show();"); //assuming you have set the widgetVar on your dialog to "myDialog"
}