<tfoot id='41T5v'></tfoot>

<legend id='41T5v'><style id='41T5v'><dir id='41T5v'><q id='41T5v'></q></dir></style></legend>
  • <small id='41T5v'></small><noframes id='41T5v'>

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

        • <bdo id='41T5v'></bdo><ul id='41T5v'></ul>

        ActionError 未显示

        ActionError not getting displayed(ActionError 未显示)

          1. <small id='nKiRL'></small><noframes id='nKiRL'>

              <bdo id='nKiRL'></bdo><ul id='nKiRL'></ul>

            • <legend id='nKiRL'><style id='nKiRL'><dir id='nKiRL'><q id='nKiRL'></q></dir></style></legend>
                <tbody id='nKiRL'></tbody>

                  <tfoot id='nKiRL'></tfoot>
                • <i id='nKiRL'><tr id='nKiRL'><dt id='nKiRL'><q id='nKiRL'><span id='nKiRL'><b id='nKiRL'><form id='nKiRL'><ins id='nKiRL'></ins><ul id='nKiRL'></ul><sub id='nKiRL'></sub></form><legend id='nKiRL'></legend><bdo id='nKiRL'><pre id='nKiRL'><center id='nKiRL'></center></pre></bdo></b><th id='nKiRL'></th></span></q></dt></tr></i><div id='nKiRL'><tfoot id='nKiRL'></tfoot><dl id='nKiRL'><fieldset id='nKiRL'></fieldset></dl></div>
                  本文介绍了ActionError 未显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  如果 Action 类返回错误,我想在 ErrorDiv 中加载我的 Error.jsp.我正在做一个 AJAX 调用.

                  I want to load my Error.jsp in my ErrorDiv if Action class returns error. I am doing an AJAX call.

                  JS:

                  success: function(result){    
                      if(result === 'success')
                          alert('Database Updated Successfully!');
                      else{
                           $('#ErrorDiv').load('/gma/pages/Error.jsp');
                      }
                  }
                  
                                  
                  

                  Error.jsp:

                  <body>
                  
                  <%
                      request.setAttribute("decorator", "none");
                      response.setHeader("Cache-Control","no-cache"); //HTTP 1.1
                      response.setHeader("Pragma","no-cache"); //HTTP 1.0
                      response.setDateHeader ("Expires", 0); //prevents caching at the proxy server
                  %>
                  <s:if test="hasActionErrors()">
                         <s:actionerror />
                  </s:if>
                  
                  </body>
                  

                  但是,不会显示操作错误.在我检查的萤火虫中,对 GET Error.jsp 的响应是 <body></body> 部分为空.

                  However, action errors are not getting displayed. In firebug I checked, response to GET Error.jsp in that the <body> </body> part comes empty.

                  为什么 actionError 不显示?

                  动作类:

                  try{
                  slsConfigureTspThresholdRemote.setThresholdParameters(circleId, tspId, thresholdTypeFlag, thresholdParametersList);
                  
                  }
                  catch (Exception e){    
                      addActionError(e.getMessage());
                      e.printStackTrace();
                      
                      result = "error";
                      return ERROR;
                  }
                  

                  struts.xml:

                  <action name="updateThresholdParameters"
                  class="cdot.oss.cmsat.gma.struts.ConfigureTspThresholdAction" method="updateThresholdParameters">
                  
                  <result name="success" type="json">
                      <param name="root">result</param>
                  </result> 
                  
                  <result name="error">pages/Error.jsp</result>
                  

                  目前,我正在执行 $('#ErrorDiv').html(result); 以便将我的 JSP 加载到 div 而不是

                  Presently, I am doing $('#ErrorDiv').html(result); so that my JSP get loaded in div instead of

                  $('#ErrorDiv').load('/gma/pages/Error.jsp');!
                  

                  推荐答案

                  验证错误只对同一个请求有效.此外,对 JSP 的直接访问可能由 Struts 标记不起作用的 Web 容器处理.

                  The validation errors are available only to the same request. Also direct access to the JSPs might be handled by the web container where the Struts tags will not work.

                  您应该使用一个动作来呈现一个 JSP,并且该动作应该运行一个 store 拦截器,如果你想保留前一个请求的验证错误.

                  You should use an action to render a JSP and the action should run a store interceptor if you want to keep the validation errors from the previous request.

                  如果您想使用相同的响应来返回不同的结果,您可以为每个结果设置不同的状态代码.

                  If you want to use the same response to return a different result you can set the different status code with each result.

                  在客户端你可以查看Ajax响应返回的状态码并做相应的事情.

                  On the client you could check the status code returned by the Ajax response and do corresponding things.

                  success: function(data, textStatus, jqXHR){
                      if(jqXHR.status == 200) {                      
                        alert('Database Updated Successfully!'); 
                      }
                  }
                  error: function(data, textStatus, jqXHR){
                      if(jqXHR.status == 400) {
                        $('#ErrorDiv').html(data);        
                      }     
                  }
                  

                  要在 JSP 中显示错误,请将以下内容添加到 scriptlet 代码中

                  To show errors in the JSP add the following to the scriptlet code

                  response.setStatus(400);
                  

                  这篇关于ActionError 未显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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 表达式)

                    <tfoot id='jHl9P'></tfoot>
                  1. <small id='jHl9P'></small><noframes id='jHl9P'>

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

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