0

我在 Struts2 中有此方法的操作方法和验证方法。我想将此验证方法用于另一种操作方法。我不知道该怎么做。请帮忙。场景描述如下:

public class ApplicantRegistrationDetails extends ActionSupport {
    
     public String personOfCollectiveTrademark() {
      // some code..
         
     }

     public String insertAndValidateIECcode(){
        // I have to use same validation method
        // for this method as above.

     }

     //validation
     public void validatePersonOfCollectiveTrademark() {
       // validations for first method
     }

}
4

1 回答 1

0

您可以使用基于前缀的方法验证轻松完成此操作。

 /**
  * Validates insertAndValidateIECcode()
  */
 public void  validateInsertAndValidateIECcode(){
    // The implementation uses same validation method
    // for personOfCollectiveTrademark().
    validatePersonOfCollectiveTrademark();
 }
于 2014-08-06T15:03:09.097 回答