Create multiple methods in one action class itself in Struts2?

后端 未结 3 778
醉酒成梦
醉酒成梦 2021-01-17 03:48

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

For example : I created a simple validation acti

3条回答
  •  日久生厌
    2021-01-17 04:14

    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

    
            /your_success_jsp.jsp
            /your_error_jsp.jsp
     
    
    
        /your_success_jsp.jsp
        /your_error_jsp.jsp
     
    

提交回复
热议问题