开发者

struts2 validate

In Struts2 you can change the method used for execution for an action by changing the method attribute in the following l开发者_开发技巧ine:

<action name="registerVal" class="cz.vutbr.fit.pishotel.model.action.Register" method="execute">

Is it possible to change the validation method used as well, or is the validate method name hardcoded.


It hard coded in the following way. If you have:

<action name="registerVal" class="cz.vutbr.fit.pishotel.model.action.Register" method="myMethod">

Then the validation interceptor will call

public void validateMyMethod() {

if (someValue == null) {

addFieldError("myField","myMessage");

}

}

If there are errors in the fieldErrors collection then INPUT will be returned for registerVal

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜