<bdo id='9ALod'></bdo><ul id='9ALod'></ul>

  1. <legend id='9ALod'><style id='9ALod'><dir id='9ALod'><q id='9ALod'></q></dir></style></legend>
  2. <small id='9ALod'></small><noframes id='9ALod'>

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

    1. 在 Struts2 中的一个动作类本身中创建多个方法?

      时间:2023-10-15
      <i id='xIeLn'><tr id='xIeLn'><dt id='xIeLn'><q id='xIeLn'><span id='xIeLn'><b id='xIeLn'><form id='xIeLn'><ins id='xIeLn'></ins><ul id='xIeLn'></ul><sub id='xIeLn'></sub></form><legend id='xIeLn'></legend><bdo id='xIeLn'><pre id='xIeLn'><center id='xIeLn'></center></pre></bdo></b><th id='xIeLn'></th></span></q></dt></tr></i><div id='xIeLn'><tfoot id='xIeLn'></tfoot><dl id='xIeLn'><fieldset id='xIeLn'></fieldset></dl></div>

          <tbody id='xIeLn'></tbody>
            <bdo id='xIeLn'></bdo><ul id='xIeLn'></ul>

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

                <tfoot id='xIeLn'></tfoot>
              1. <legend id='xIeLn'><style id='xIeLn'><dir id='xIeLn'><q id='xIeLn'></q></dir></style></legend>

                本文介绍了在 Struts2 中的一个动作类本身中创建多个方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我可以在同一个动作类中创建两个方法吗?如果是这样,我们如何在 struts.xml 文件中指定它?

                Can I create two methods in the same Action Class? If so how can we specify it in the struts.xml file ?

                例如:我创建了一个简单的验证操作类来验证 email address 以及 password 使用两个单独的正则表达式.我在 Action 类中创建了两个方法:emailVerification()passVerification().我在里面编写了所有必要的验证代码,但是现在当它们返回 SUCCESS 时,它们应该会产生相同的成功页面结果,对于 ERROR 也是如此..

                For example : I created a simple validation action class to validate the email address as well as password using two separate regular expression. I created two Methods in the Action class say: emailVerification() and passVerification(). I wrote all the necessary validation code inside, but now when they return SUCCESS they should result into the same success page result and for ERROR likewise..

                推荐答案

                是的,您可以在 Action Class 中创建任意数量的方法.你可以这样做

                Yes you can create any number of methods in an Action Class. You can do something like this

                package com.myvalidation;
                
                public class MyValidationClass extends ActionSupport
                {
                     public String emailVerification() throws Exception
                     {
                         //Your validation logic for email validation
                         return SUCCESS;
                     }
                
                     public String passVerification() throws Exception
                     {
                         //Your validation logic for password validation
                         return SUCCESS;
                     }
                }
                

                struts.xml

                <action name="emailVerification" method="emailVerification" class="com.myvalidation.MyValidationClass">
                        <result name="success">/your_success_jsp.jsp</result>
                        <result name="input">/your_error_jsp.jsp</result>
                </action> 
                
                <action name="passVerification" method="passVerification" class="com.myvalidation.MyValidationClass">
                    <result name="success">/your_success_jsp.jsp</result>
                    <result name="input">/your_error_jsp.jsp</result>
                </action> 
                

                这篇关于在 Struts2 中的一个动作类本身中创建多个方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:令牌拦截器如何在 Struts 2 中工作 下一篇:我可以在一个 Web 应用程序中有两个 web.xml 文件吗?

                相关文章

                <legend id='cKCQx'><style id='cKCQx'><dir id='cKCQx'><q id='cKCQx'></q></dir></style></legend>
                  <bdo id='cKCQx'></bdo><ul id='cKCQx'></ul>

                <tfoot id='cKCQx'></tfoot>

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