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

    <tfoot id='oZFyz'></tfoot>
    • <bdo id='oZFyz'></bdo><ul id='oZFyz'></ul>

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

    1. <legend id='oZFyz'><style id='oZFyz'><dir id='oZFyz'><q id='oZFyz'></q></dir></style></legend>
    2. 如何从struts 2 中的java 脚本重定向到struts 动作?

      时间:2023-10-12
    3. <tfoot id='8FMh4'></tfoot>
          <legend id='8FMh4'><style id='8FMh4'><dir id='8FMh4'><q id='8FMh4'></q></dir></style></legend>

            <tbody id='8FMh4'></tbody>

            1. <small id='8FMh4'></small><noframes id='8FMh4'>

              <i id='8FMh4'><tr id='8FMh4'><dt id='8FMh4'><q id='8FMh4'><span id='8FMh4'><b id='8FMh4'><form id='8FMh4'><ins id='8FMh4'></ins><ul id='8FMh4'></ul><sub id='8FMh4'></sub></form><legend id='8FMh4'></legend><bdo id='8FMh4'><pre id='8FMh4'><center id='8FMh4'></center></pre></bdo></b><th id='8FMh4'></th></span></q></dt></tr></i><div id='8FMh4'><tfoot id='8FMh4'></tfoot><dl id='8FMh4'><fieldset id='8FMh4'></fieldset></dl></div>
                <bdo id='8FMh4'></bdo><ul id='8FMh4'></ul>
              • 本文介绍了如何从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 动作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:如何在 Struts2 应用程序中为 AJAX 请求做 CSRF 保护 下一篇:sp_send_dbmail - 将表格中的行格式化为红色以发出警

                相关文章

                最新文章

              • <small id='FWeq7'></small><noframes id='FWeq7'>

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