Pages Navigation Menu

Coding is much easier than you think

How to exclude action methods from validation in struts2

How to exclude action methods from validation in struts2



My Action class have the following methods,
1.addAction
2.deleteAction
3.updateAction
4.populateAction
 
** UPDATE: Struts 2 Complete tutorial now available here.
 
Consider a scenario where I want to apply validation for addAction and deleteAction method alone and not for other method , then all you to do a configuration in struts.xml file by listing all the methods you don’t want to be run through the validation framework in the excludeMethods parameter. Since we only want addElement and deleteElement validated, list the other two methods as follows:
 

<interceptor-ref name="validation">
    <param name="excludeMethods">updateAction,populateAction</param>
</interceptor-ref>

 

About Mohaideen Jamil


Am currently working as a Struts 2 Developer in a reputed IT Organisations. I can help you with teaching Core java and Struts 2. Follow me on Facebook or Google Plus. If you like my tutorials, consider making a donation to this charity, thanks.

  • Vasudeo

    Please show full struts.xml file with configured validation interceptor having excludeMethod parameters.

  • Vasudeo

    I have multiple action tag in my struts.xml having only method name diffrerent so where exactly i have to plug ,

    updateAction,populateAction

    • http://www.simplecodestuffs.com Mohaideen Jamil

      Just create the above interceptor and include it before every action class where ever you want to exclude the validation