Struts 2 validate specific action in xml

前端 未结 3 483
鱼传尺愫
鱼传尺愫 2021-01-26 13:30

I want to validate specific method only in action class. Action method is this.

public String add() throws Exception {

         


        
3条回答
  •  执念已碎
    2021-01-26 14:04

    To exclude some methods from validation you can override parameters of the validation interceptor. For example in interceptor stack you can write

    
      input,back,cancel,browse,yourmethod
    
    

    in the action configuration you can use above code and

    
      input,back,cancel,browse,yourmethod
    
    

    Note yourmethod is a method name.

    You can specify a validation.xml for only one action by a postfix of action name in this file. For example AcrionClass-add-validation.xml will work only for the action name add in the action config. Note here add is an action name, not a method name.

    Often, the name attribute matches the method name, but they may also differ.

提交回复
热议问题