[英]Not able to call two different methods under same action class without using validation.excludeMethods
[英]How to use same validation method for two action methods
我在 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
}
}
您可以通過使用基於前綴的方法驗證輕松完成。
/**
* Validates insertAndValidateIECcode()
*/
public void validateInsertAndValidateIECcode(){
// The implementation uses same validation method
// for personOfCollectiveTrademark().
validatePersonOfCollectiveTrademark();
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.