JSF 1.2 将参数添加到重定向请求



我使用 Jsf 1.2 并且具有带有重定向的导航规则,我的问题是如何添加请求参数以查看重定向

在 JSF 1.x 中使用导航规则无法做到这一点。请改用ExternalContext#redirect()

public void action() throws IOException {
    // ...
    ExternalContext ec = FacesContext.getCurrentInstance().getExternalContext();
    String url = ec.getRequestContextPath() + "/page.jsf?someparam=" + URLEncoder.encode(someparam, "UTF-8");
    ec.redirect(url);
}

最新更新