jsf自动生成,异常java.lang.IllegalStateException:提交响应后无法转发

jsf自动生成,异常java.lang.IllegalStateException:提交响应后无法转发,jsf,Jsf,我曾尝试使用JSF1.2制作自动生成表单,但在重定向方面有一些例外 Bean代码 public class UserAutorisationBean implements Serializable { private Boolean isLogin = false; private String login = ""; private String password = ""; public void autoriseLoginAndPass() throws

我曾尝试使用JSF1.2制作自动生成表单,但在重定向方面有一些例外

Bean代码

public class UserAutorisationBean implements Serializable {

    private Boolean isLogin = false;
    private String login = "";
    private String password = "";

    public void autoriseLoginAndPass() throws IOException {
        if (this.login == "user" && this.password == "password") {
            this.isLogin = true;
            FacesContext context = FacesContext.getCurrentInstance();
            HttpServletResponse response = 
                    (HttpServletResponse) context.getExternalContext().getResponse();

            response.sendRedirect("web/HelloWorld.jsp");
        } else {
            FacesContext context = FacesContext.getCurrentInstance();
            HttpServletResponse response = 
                    (HttpServletResponse) context.getExternalContext().getResponse();

            response.sendRedirect("web/Error.jsp");
        }

    }
过滤代码

public class Filter implements javax.servlet.Filter {

    public void init(FilterConfig filterConfig) throws ServletException {

    }

    public void doFilter(ServletRequest request, ServletResponse response,
                         FilterChain chain) throws IOException, ServletException {

        HttpServletRequest httpRequest = (HttpServletRequest) request;
        HttpServletResponse httpResponse = (HttpServletResponse) response;
        HttpSession session = null;
        session = httpRequest.getSession(false);

        if (session != null) {
            UserAutorisationBean userAutorisationBean = null;
            userAutorisationBean =
                    (UserAutorisationBean) session.getAttribute("userautorisationbean");

            if (userAutorisationBean != null) {
                if (!userAutorisationBean.isLoginIn()) {
                    httpResponse.sendRedirect(httpRequest.getContextPath() + "/Error.jsp");
                }
            }
            chain.doFilter(request, response);
        }
        if (session == null) {
            httpResponse.sendRedirect(httpRequest.getContextPath() + "/Error.jsp");
        }
    }

    public void destroy() {

    }

}
堆栈: 提交响应后无法转发消息

说明服务器遇到内部错误,无法满足此请求

例外情况

javax.servlet.ServletException: Cannot forward after response has been committed
    javax.faces.webapp.FacesServlet.service(FacesServlet.java:256)
root cause

java.lang.IllegalStateException: Cannot forward after response has been committed
    com.sun.faces.context.ExternalContextImpl.dispatch(ExternalContextImpl.java:414)
    com.sun.faces.application.ViewHandlerImpl.executePageToBuildView(ViewHandlerImpl.java:455)
    com.sun.faces.application.ViewHandlerImpl.renderView(ViewHandlerImpl.java:139)
    com.sun.faces.lifecycle.RenderResponsePhase.execute(RenderResponsePhase.java:108)
    com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:266)
    com.sun.faces.lifecycle.LifecycleImpl.render(LifecycleImpl.java:159)
    javax.faces.webapp.FacesServlet.service(FacesServlet.java:245)

我试图通过使用搜索找到一些建议,但它并没有帮助我解决问题。

每次当JSF初学者试图从
FacesContext
的封面下提取并向下转换原始的
javax.servlet.
API时,IDE应该会在屏幕上以黑红色闪烁,并显示一条大的警告消息“你确定要这么做吗?
ExternalContext
本身中是否真的没有您应该使用的东西?“