<!DOCTYPE validators PUBLIC "-//OpenSymphony Group//XWork Validator 1.0.2//EN"
<message>Employee Name is required.</message>
It is *required to have both getters and setters for the field you are validating for. As class AddEmployee will require both of the following method signatures for validation to work properly: “public String getEmployeeId()” and “public void setEmployeeId(String EmployeeId)”. You can get more information about the other types of validators at official site of struts – Struts 2 documentation.
You can also control error handling from your Action class. For example, let’s say that the user picks a username which is already registered. We wouldn’t be able to determine this with validation alone, but would need to check the database in our Action class. So when we determine that we can call “addActionError(String message)” from our class. Then when we want to print any errors out on our page, we simply use the tag into our error page where we sould like to show error message: <s:actionerror />