如何在Struts 2的一个动作类中使用不同的验证方法

VIV*_*VEK 4 java validation struts2 struts2-interceptors

我有一个动作类,它有两个动作方法。我想要单独的验证方法。我是Struts2的新手。我想要这样的东西。我认为可以通过验证拦截器实现,但是如何呢?

public class ApplicantRegistration extends ActionSupport{

 public String method1(){
   // validate1
 }

 public String method2(){
   // validate2
 }

 @override
 public void validate1(){
  // validations
 }

 public void validate2(){
 //validations
 }

}
Run Code Online (Sandbox Code Playgroud)

Rom*_*n C 5

要对方法进行单独验证,请使用validate前缀

public class ApplicantRegistration extends ActionSupport{

 public String method1(){
   // action1
 }

 public String method2(){
   // action2
 }

 public void validateMethod1(){
  // validate method1
 }

 public void validateMethod2(){
  // validate method2
 }

}
Run Code Online (Sandbox Code Playgroud)