开发者

struts2 validate

开发者 https://www.devze.com 2022-12-28 18:42 出处:网络
In Struts2 you can change the method used for execution for an action by changing the method attribute in the following l开发者_开发技巧ine:

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

精彩评论

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

关注公众号