我在Struts2 WebApp中工作,并且在尝试发送邮件时不在第一次单击时进行邮件,第二次单击工作。

发布于 2025-02-08 09:30:53 字数 3020 浏览 2 评论 0原文

我正在Struts2 WebApp中工作,并且在尝试发送邮件时,它在第一次单击时无法使用,因为当我单击第二次工作时,并且如果我评论&lt; interceptor-ref name =“ token” /&gt; < /代码>然后首次单击。

时,首先单击时单击。

注意:1。仅在我注释&lt; interceptor-ref name =“ token”/&gt;这是我的struts.xml代码

<action name="myActionName" class="actions.myActionName"
            method="myActionName">
            <interceptor-ref name="token" />
            <interceptor-ref name="params" />
            <interceptor-ref name="basicStack" />
            <exception-mapping result="passRecoveryException"
                exception="exceptions.PasswordRecoveryException" />
            <result name="success" type="json" />
            <result name="passRecoveryException" type="json" />
            <result name="invalid.token">/index.jsp</result>
        </action>

,我正在使用jQuery在第一次单击时从Frontent发送邮件

$(document).on('click','#myActionNameId',function(){
    if($("#username").val() == ""){
        showToaster(2,"This field is required."," User name");
        return false;
    }else if ($("#email").val() == ""){
        showToaster(2,"This field is required."," Email ID");
        return false;
    }/*else if ($("#captchaText").val() == ""){
        showToaster(2,"This field is required."," Captcha");
        return false;
    }*/else if(grecaptcha.getResponse().length==0){
        showToaster(2,"Please verify your captcha","Captcha");
        return false;
    }
    
    else{

        $('#loading').show();
        var form = $('#forgotPassForm');
        var formdata = false;
        if (window.FormData){
            formdata = new FormData(form[0]);
        }
        var formAction = form.attr('action');
        submitByAjaxWithConfirmwithCallBackJSON(formAction,formdata,function(data){
            //alert(data.exception);
            if(data.exception==undefined){
                 if(data.success==true){
                    $('#loading').hide();
                    showToaster(1,data.message.split(':')[1],data.message.split(':')[0]);
                 }else{
                     showToaster(2,data.message.split(':')[1],data.message.split(':')[0]);
                     $('#loading').hide();
                 }
            }else{
                var msg = data.exception.message.split(':');
                showToaster(2,msg[1],msg[0]);
                //alert(msg[0]);
                $('#loading').hide();
            }
        })
    }
});

,它将转到

 if(data.success==true){
                    $('#loading').hide();
                    showToaster(1,data.message.split(':')[1],data.message.split(':')[0]);
                 }else{
                     showToaster(2,data.message.split(':')[1],data.message.split(':')[0]);
                     $('#loading').hide();
                 }

else 零件,但是第二次再次单击以发送其工作正常。

I am working in Struts2 webapp and while trying to send mail it's not working on first click where as when I clicked second time it's working and aslo if I comment the <interceptor-ref name="token" /> then it's working on first click.

NOTE: 1. On first click working only if I comment<interceptor-ref name="token" />

Here's my struts.xml code

<action name="myActionName" class="actions.myActionName"
            method="myActionName">
            <interceptor-ref name="token" />
            <interceptor-ref name="params" />
            <interceptor-ref name="basicStack" />
            <exception-mapping result="passRecoveryException"
                exception="exceptions.PasswordRecoveryException" />
            <result name="success" type="json" />
            <result name="passRecoveryException" type="json" />
            <result name="invalid.token">/index.jsp</result>
        </action>

and I'm sending mail from frontent using jquery

$(document).on('click','#myActionNameId',function(){
    if($("#username").val() == ""){
        showToaster(2,"This field is required."," User name");
        return false;
    }else if ($("#email").val() == ""){
        showToaster(2,"This field is required."," Email ID");
        return false;
    }/*else if ($("#captchaText").val() == ""){
        showToaster(2,"This field is required."," Captcha");
        return false;
    }*/else if(grecaptcha.getResponse().length==0){
        showToaster(2,"Please verify your captcha","Captcha");
        return false;
    }
    
    else{

        $('#loading').show();
        var form = $('#forgotPassForm');
        var formdata = false;
        if (window.FormData){
            formdata = new FormData(form[0]);
        }
        var formAction = form.attr('action');
        submitByAjaxWithConfirmwithCallBackJSON(formAction,formdata,function(data){
            //alert(data.exception);
            if(data.exception==undefined){
                 if(data.success==true){
                    $('#loading').hide();
                    showToaster(1,data.message.split(':')[1],data.message.split(':')[0]);
                 }else{
                     showToaster(2,data.message.split(':')[1],data.message.split(':')[0]);
                     $('#loading').hide();
                 }
            }else{
                var msg = data.exception.message.split(':');
                showToaster(2,msg[1],msg[0]);
                //alert(msg[0]);
                $('#loading').hide();
            }
        })
    }
});

on first click it's going to

 if(data.success==true){
                    $('#loading').hide();
                    showToaster(1,data.message.split(':')[1],data.message.split(':')[0]);
                 }else{
                     showToaster(2,data.message.split(':')[1],data.message.split(':')[0]);
                     $('#loading').hide();
                 }

else part but after second time when I again click to send it's working fine.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文