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

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

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

        <small id='NzIWD'></small><noframes id='NzIWD'>

        如何从struts 2 中的java 脚本重定向到struts 动作?

        how to redirect to struts action from java script in struts 2?(如何从struts 2 中的java 脚本重定向到struts 动作?)
        <legend id='DWeHA'><style id='DWeHA'><dir id='DWeHA'><q id='DWeHA'></q></dir></style></legend>
            <tbody id='DWeHA'></tbody>

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

              • <tfoot id='DWeHA'></tfoot>

                  本文介绍了如何从struts 2 中的java 脚本重定向到struts 动作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  如何从 java 脚本重定向到 struts 动作?

                  how to redirect to struts action from java script?

                  如果脚本中的条件成功,那么我需要在配置 xml 中调用一个操作,否则调用控件的任何操作都不需要停留在同一页面上?请帮忙?

                  if condition in the script got success then i need to invoke one action in the config xml, otherwise no action invoking the control needs to stay at same page? please help on this?

                  Java 脚本

                      function displayDate()
                  {
                  
                         var x=document.getElementsByName("userName")
                      if(x = "shan")
                      {   
                      alert("shankarasd");
                      document.myForm.action ="/setUpForInsertOrUpdate";
                      document.myForm.submit();
                      }
                  
                  }
                  

                  HTML

                      <html>
                          <body>
                          <s:form action="HelloWorld" >
                              <s:textfield name="userName" label="User Name" />
                              <s:submit onclick="displayDate()" />
                          </s:form>
                      </body>
                  </html>
                  

                  config.xml

                   <struts>
                      <package name="default" extends="struts-default">
                          <action name="HelloWorld" class="vaannila.HelloWorld.HelloWorld"> 
                              <result name="SUCCESS">/success.jsp</result>
                          </action>
                          <action name="setUpForInsertOrUpdate" method="setUpForInsertOrUpdate" class="vaannila.HelloWorld.HelloWorld">
                              <result name="SUCCESS1">/success1.jsp</result>
                          </action>
                          <action name="back" method="back" class="vaannila.HelloWorld.HelloWorld">
                              <result name="SUCCESS2">/success.jsp</result>
                          </action>
                      </package>
                  </struts> 
                  

                  推荐答案

                  试试看

                  window.location='youractionname'
                  

                  这会将您的窗口重定向到您的目的地

                  This will redirect your window into your destination

                  如果您想将您的值发送到其他页面,请按照此方法

                  If you want to sent your values to other page, then follow this method

                  <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
                      pageEncoding="ISO-8859-1"%>
                  <%@ taglib prefix="s" uri="/struts-tags" %>
                  <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
                  <html>
                  <head>
                  <script type="text/javascript">
                  
                  function displayDate()
                  {
                  
                     var x=document.getElementsByName("userName")
                  if(x =="shan")
                  {   
                  alert("Redirecting");
                  return true;
                  }
                  else{  
                  alert("Not Redirecting");
                  return false;
                  }
                  }
                  </script>
                  
                  <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
                  <title>Insert title here</title>
                  </head>
                  <body>
                    <s:form action="HelloWorld"  onsubmit="displayDate();">
                          <s:textfield name="userName" label="User Name" />
                          <s:submit onclick="displayDate()" />
                      </s:form>
                  </body>
                  </html>
                  

                  我修改的是,将函数调用从按钮更改为表单提交.并从函数中删除不需要的东西

                  What I modified is, changed the function calling from button to form submit. And removed the unwanted things from function

                  这篇关于如何从struts 2 中的java 脚本重定向到struts 动作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  What are valid deviceNames for Chrome emulation testing with Protractor?(使用 Protractor 进行 Chrome 模拟测试的有效设备名称是什么?)
                  Protractor Check if Element Does Not Exist(量角器检查元素是否不存在)
                  Protractor e2e Tests Login Redirection(Protractor e2e 测试登录重定向)
                  Explain about async/ await in Protractor(解释 Protractor 中的 async/await)
                  Protractor browser.wait doesn#39;t wait(量角器 browser.wait 不等待)
                  How to use Protractor with Angular 2?(如何在 Angular 2 中使用量角器?)
                      <legend id='XNUR5'><style id='XNUR5'><dir id='XNUR5'><q id='XNUR5'></q></dir></style></legend>
                      • <bdo id='XNUR5'></bdo><ul id='XNUR5'></ul>

                          <small id='XNUR5'></small><noframes id='XNUR5'>

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