• <i id='8oQlt'><tr id='8oQlt'><dt id='8oQlt'><q id='8oQlt'><span id='8oQlt'><b id='8oQlt'><form id='8oQlt'><ins id='8oQlt'></ins><ul id='8oQlt'></ul><sub id='8oQlt'></sub></form><legend id='8oQlt'></legend><bdo id='8oQlt'><pre id='8oQlt'><center id='8oQlt'></center></pre></bdo></b><th id='8oQlt'></th></span></q></dt></tr></i><div id='8oQlt'><tfoot id='8oQlt'></tfoot><dl id='8oQlt'><fieldset id='8oQlt'></fieldset></dl></div>
    <legend id='8oQlt'><style id='8oQlt'><dir id='8oQlt'><q id='8oQlt'></q></dir></style></legend>

    • <bdo id='8oQlt'></bdo><ul id='8oQlt'></ul>

    <small id='8oQlt'></small><noframes id='8oQlt'>

  • <tfoot id='8oQlt'></tfoot>
      1. 如何在 Struts 2 中使用 jQuery Ajax 检查唯一用户?

        How to check for an unique user with jQuery Ajax in Struts 2?(如何在 Struts 2 中使用 jQuery Ajax 检查唯一用户?)

              <bdo id='9lBMr'></bdo><ul id='9lBMr'></ul>
              • <i id='9lBMr'><tr id='9lBMr'><dt id='9lBMr'><q id='9lBMr'><span id='9lBMr'><b id='9lBMr'><form id='9lBMr'><ins id='9lBMr'></ins><ul id='9lBMr'></ul><sub id='9lBMr'></sub></form><legend id='9lBMr'></legend><bdo id='9lBMr'><pre id='9lBMr'><center id='9lBMr'></center></pre></bdo></b><th id='9lBMr'></th></span></q></dt></tr></i><div id='9lBMr'><tfoot id='9lBMr'></tfoot><dl id='9lBMr'><fieldset id='9lBMr'></fieldset></dl></div>
                  <tbody id='9lBMr'></tbody>

                <legend id='9lBMr'><style id='9lBMr'><dir id='9lBMr'><q id='9lBMr'></q></dir></style></legend>

                <small id='9lBMr'></small><noframes id='9lBMr'>

              • <tfoot id='9lBMr'></tfoot>

                  本文介绍了如何在 Struts 2 中使用 jQuery Ajax 检查唯一用户?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有任何应用程序,其中我的 email_id 是唯一的,当最终用户输入他的 email_id 时,我通过 Ajax 触发了 SQL 查询,它检查这是否 email_id 存在与否.直到这里它工作正常,但现在我如果 email_id 存在,那么我想在 JSP 页面上显示它,比如这个 id 已经被占用".反之亦然.

                  I'm having any application in which I have email_id as unique and when the end user enters his email_id I have fired SQL query through Ajax which check whether this email_id exists or not. Until here it's working fine but now I what if that email_id exists then I want to display it on the JSP page like "This id is already taken" and vice-versa.

                  所以我的问题是如何从 Struts 应用程序获取响应并将其提供给 Ajax 或 JSP 页面以及在 struts.xml 结果标签中写什么?

                  So my question is how to get the response from Struts app and give it to Ajax or JSP page and what to write in struts.xml result tag?

                  这是我对 EmailCheck.action 的 Ajax 调用:

                  This is my Ajax call to EmailCheck.action:

                  $("#email").blur(function() {
                        var EmailV = $("#email").val();
                          if(EmailV.length > 10){
                              $('#Loading').show();
                              $.get("EmailCheck.action", {
                                  Email_Id: EmailV   
                              }, function(response){
                                  $('#Info').fadeOut();
                                  $('#Loading').hide();
                                  setTimeout("finishAjax('Info', '"+escape(response)+"')", 450);
                              });
                              return false;
                          }
                      });
                  

                  这是我的 struts.xml:

                  这个电子邮件类型检查器应该有结果标签吗?

                  Should there be result tag for this Email type checker?

                   <action name="EmailCheck"  class="org.register.customers.EmailCheckAction" method="EmailCheck">
                            <result name="input">index.jsp</result>
                            <result name="success">success.jsp</result>
                            <result name="error">error.jsp</result>
                    </action>
                  

                  这是我的操作代码:

                  This is my Action code:

                   public String EmailCheck() throws Exception{
                           
                       System.out.println(user.getEmail_Id());
                  
                         boolean create = Check_Email(user);
                  
                   //  "this is my sql call to check the existence of email"
                  
                      if (true) {       
                         
                          return "input";
                      } else {          
                          
                          return ERROR;
                      }        
                  }
                  

                  推荐答案

                  如果您调用 Ajax 操作,您可以返回 dispatcher 结果.在这种情况下,渲染的 JSP 片段将作为响应输出.此外,您可以选择返回 streamjsonnone 结果.对于您的情况,我将考虑第一种选择.首先查看this 答案,让您熟悉如何使用 返回 stream 结果text/html 内容类型.然后在 JSP 中,您应该在放置响应的位置创建一个目标 div.

                  If you call an Ajax action you can return a dispatcher result. In this case a rendered JSP fragment will output as a response. Also, you have options to return a stream, json, or none results. To your case I will consider the first option. First look at this answer to get you familiar how to return a stream result with text/html content type. Then in the JSP you should create a target div where you put the response.

                  <div id="result"/>
                  

                  现在修改您的 JS 以将结果插入到 div 中.

                  now modify your JS to insert result into div.

                  }, function(response){
                    $("result").html(response);
                  

                  这篇关于如何在 Struts 2 中使用 jQuery Ajax 检查唯一用户?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Compiling C++ for the JVM(为 JVM 编译 C++)
                  Compile to java bytecode (without using Java)(编译成java字节码(不使用Java))
                  How to drive C#, C++ or Java compiler to compute 1+2+3+...+1000 at compile time?(如何在编译时驱动 C#、C++ 或 Java 编译器计算 1+2+3+...+1000?)
                  Java ClassLoader: load same class twice(Java ClassLoader:两次加载相同的类)
                  How to debug .class files in ECLIPSE?(如何在 ECLIPSE 中调试 .class 文件?)
                  Java quot;The blank final field may not have been initializedquot; Anonymous Interface vs Lambda Expression(Java“可能尚未初始化空白的最终字段匿名接口与 Lambda 表达式)
                1. <tfoot id='rIdYy'></tfoot>
                2. <small id='rIdYy'></small><noframes id='rIdYy'>

                  <legend id='rIdYy'><style id='rIdYy'><dir id='rIdYy'><q id='rIdYy'></q></dir></style></legend>

                      • <bdo id='rIdYy'></bdo><ul id='rIdYy'></ul>

                      • <i id='rIdYy'><tr id='rIdYy'><dt id='rIdYy'><q id='rIdYy'><span id='rIdYy'><b id='rIdYy'><form id='rIdYy'><ins id='rIdYy'></ins><ul id='rIdYy'></ul><sub id='rIdYy'></sub></form><legend id='rIdYy'></legend><bdo id='rIdYy'><pre id='rIdYy'><center id='rIdYy'></center></pre></bdo></b><th id='rIdYy'></th></span></q></dt></tr></i><div id='rIdYy'><tfoot id='rIdYy'></tfoot><dl id='rIdYy'><fieldset id='rIdYy'></fieldset></dl></div>
                              <tbody id='rIdYy'></tbody>