<bdo id='0QP05'></bdo><ul id='0QP05'></ul>
    1. <legend id='0QP05'><style id='0QP05'><dir id='0QP05'><q id='0QP05'></q></dir></style></legend>

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

    2. <small id='0QP05'></small><noframes id='0QP05'>

      如何使用javascript调用Struts2 Action Class方法中的方

      时间:2023-10-12
    3. <i id='6OGWi'><tr id='6OGWi'><dt id='6OGWi'><q id='6OGWi'><span id='6OGWi'><b id='6OGWi'><form id='6OGWi'><ins id='6OGWi'></ins><ul id='6OGWi'></ul><sub id='6OGWi'></sub></form><legend id='6OGWi'></legend><bdo id='6OGWi'><pre id='6OGWi'><center id='6OGWi'></center></pre></bdo></b><th id='6OGWi'></th></span></q></dt></tr></i><div id='6OGWi'><tfoot id='6OGWi'></tfoot><dl id='6OGWi'><fieldset id='6OGWi'></fieldset></dl></div>
    4. <small id='6OGWi'></small><noframes id='6OGWi'>

        1. <legend id='6OGWi'><style id='6OGWi'><dir id='6OGWi'><q id='6OGWi'></q></dir></style></legend>

            <tbody id='6OGWi'></tbody>

            • <tfoot id='6OGWi'></tfoot>
                <bdo id='6OGWi'></bdo><ul id='6OGWi'></ul>
                本文介绍了如何使用javascript调用Struts2 Action Class方法中的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                问题描述

                我们目前使用以下 javascript 在其中一个字段值更改时提交表单.

                We currently use the following javascript to submit the form when one of the field values change.

                var url = "project/location/myAction.action?name="+ lname ; 
                document.forms[0].action = url;
                document.forms[0].submit();
                

                调用以下 Struts2 动作

                which calls the following Struts2 action

                <action name="myAction" class="project.location.NameAction">
                    <result name="success" type="tiles">myAction</result>   
                </action>
                

                然后转到 Action 类 NameActionexecute() 方法,我必须检查表单是否是从 javascript 提交的.

                which then goes to the execute() method of the Action class NameAction where I have to check to see if the form was submitted from the javascript.

                我更愿意直接从 javascript 调用 NameAction 中的 findName() 方法.换句话说,我希望 javascript 的行为类似于以下 jsp 代码.

                I would prefer to call the findName() method in NameAction directly from the javascript. In other words I want the javascript to act like the following jsp code.

                <s:submit method="findName" key="button.clear" cssClass="submit" >
                

                推荐答案

                实现你想要的有不同的方法,但可能更简单的是将不同的动作映射到同一个动作类文件的不同方法,例如.带注释:

                There are different ways to achieve what you want, but probably the simpler is to map different actions to different methods of the same action class file, eg. with annotations:

                public class NameAction {
                
                    @Action("myAction")
                    public String execute(){ ... }
                
                    @Action("myActionFindName")
                    public String findName(){ ... }
                
                }
                

                或使用 XML:

                <action name="myAction" class="project.location.NameAction">
                    <result name="success" type="tiles">myAction</result>   
                </action>
                
                <action name="myActionFindName" class="project.location.NameAction" method="findName">
                    <result name="success" type="tiles">myAction</result>   
                </action>
                

                然后在javascript中:

                Then in javascript:

                var url = "project/location/myActionFindName.action?name="+ lname ;
                

                这篇关于如何使用javascript调用Struts2 Action Class方法中的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                上一篇:将 Java 对象转换为 JSON? 下一篇:Boostrap 与 Struts 2 兼容吗?

                相关文章

                最新文章

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

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

                  1. <tfoot id='GLEZk'></tfoot>
                    • <bdo id='GLEZk'></bdo><ul id='GLEZk'></ul>