The validation framework requires the result named "input"
in the action configuration exist, if the validation errors occurred ( or you added them in the validate()
method via addActionError()
and addFieldError()
) then by default this result will be returned by the action before its execution.
@Action(value = "addnew", results = {
@Result(name = "input", location = "/pages/addnew.jsp"),
}, interceptorRefs = @InterceptorRef("validationWorkflowStack"))
public class AddnewAction extends ActionSupport {
Results are placed inside the action annotation, there could be many results separated by comma, I have remained only one that is important to validation. The referenced interceptor stack is a minimal stack that processes the validation, it's also a subset of the default stack.
If you put annotation on action then method execute will call, otherwise you need to put the action annotation on the method. There are many possibilities to configure action mapping and method execution.
You may also add result "input" like in this tutorial, actions are mapped by convention, or use the validation annotations to perform validation like in this example. Actually I didn't get what kind of annotations you need.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…