I want to validate specific method only in action class. Action method is this.
public String add() throws Exception {
Use an action alias: map different methods of an Action to different action aliases in struts.xml, and instead of the single yourAction-validation.xml
file, add a yourAction-yourAlias-validation.xml
for the validators you want to perform for that method only.
Read more here.
EDIT
No its not validation anything now.
You cannot leave the aoName address field empty. name is
OraganisationAction-add-validation.xml
and put it with action class package. Is there anything to enable validation in struts.xml ?
If you have a correctly configured (for example the default) Interceptor Stack, validation is already enabled. If you are using a file named OraganisationAction-add-validation.xml
, that means that:
OraganisationAction.java
;your action mapping in struts.xml must be the following:
yourResult.jsp
Look for typos, check your Interceptor Stack, and it will work automatically.