HTTPError这样的:HTTP传输返回一个0状态code [英] httpError: The Http Transport returned a 0 status code

查看:2893
本文介绍了HTTPError这样的:HTTP传输返回一个0状态code的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个登录页面:

<h:form id="f_login" >
    <f:passThroughAttribute name="data-ajax" value="false" />

    <h:messages id="message" showDetail="false" errorClass="error_msg" fatalClass="success_msg" infoClass="info_msg" warnClass="warning_msg" />

    <h:inputText value="#{loginWEB.user.email}" >
        <f:passThroughAttribute name="placeholder" value="Email" />
        <f:ajax event="change" execute="@this" />
    </h:inputText>

    <h:inputSecret value="#{loginWEB.user.senha}" autocomplete="off" >
        <f:passThroughAttribute name="placeholder" value="Senha" />
        <f:ajax event="change" execute="@this" />
    </h:inputSecret>

    <h:commandButton id="btn_login" value="Login" action="#{loginWEB.login()}" >
        <f:passThroughAttribute name="data-theme" value="g" />
        <f:ajax render="message" />
    </h:commandButton>
</h:form>

通过这种操作方法:

public void login() {
    try {

        FacesContext context = FacesContext.getCurrentInstance();

        if (...) { //Verify email and password
            context.getExternalContext().redirect("/templates/main.xhtml"); 
        }
        else {
            FacesMessage message = new FacesMessage("Invalid email or password");
            message.setSeverity(FacesMessage.SEVERITY_ERROR);
            context.addMessage(null, message);
        }

    } catch (Exception e) {
        Logger.getLogger(LoginWEB.class.getName()).log(Level.SEVERE, null, e);
    }
}

提交这种形式有时会导致JS错误:

Submitting this form sometimes causes a JS error:

HTTPError这样的:HTTP传输返回一个0状态code。这通常是混合Ajax和充分的请求的结果。这通常是不希望,为性能和数据完整性的原因。

httpError: The Http Transport returned a 0 status code. This is usually the result of mixing ajax and full requests. This is usually undesired, for both performance and data integrity reasons.

我不明白我在做什么错。这是怎么造成的,我该怎么解决呢?

I don't understand what I'm doing wrong. How is this caused and how can I solve it?

推荐答案

最后,我找到了真正的问题。

Finally I found the real problem.

验证后,和之前的重定向,我在会议上提出了一些变数。 但我把对象的名单,并正在采取长的时间来做到这一点。

After the verification, and before the redirect, I put some variables in my session. But I was putting a list of object, and it was taking long time to do it.

大概是JSF是由回归仍在等待做Ajax请求和完成之前,我刷新页面,导致错误。

Probably the jsf was still waiting by the return to do the ajax request and before finish it I was refreshing the page, causing the error.

我删除了,现在一切都很好再次^^

I removed it, and now everything is fine again ^^

感谢您这么多@BalusC和@bhdrk的告诉我正确的方法来使用。

Thank you so much to @BalusC and @bhdrk for show me the right approach to use.

这篇关于HTTPError这样的:HTTP传输返回一个0状态code的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆