盾怪网教程:是一个免费提供流行杀毒软件教程、在线学习分享的学习平台!

Struts的动态表单的应用

时间:2025/1/4作者:未知来源:盾怪网教程人气:

[摘要](str.length() == 0)); public ActionErrors validate(ActionMapping mapping, HttpServletRequest reque...
(str.length() == 0));
}

public ActionErrors validate(ActionMapping mapping,
HttpServletRequest request) {
ActionErrors errors = new ActionErrors();
if (nullOrBlank((String)this.get("lastName"))) {
errors.add("lastName",
new ActionError("article1.lastName.missing"));
}
if (nullOrBlank((String)this.get("firstName"))) {
errors.add("firstName",
new ActionError("article1.firstName.missing"));
}
if (nullOrBlank((String)this.get("street"))) {
errors.add("street",
new ActionError("article1.street.missing"));
}
if (nullOrBlank((String)this.get("city"))) {
errors.add("city", new ActionError("article1.city.missing"));
}
if (nullOrBlank((String)this.get("state"))) {
errors.add("state",
new ActionError("article1.state.missing"));
}
if (nullOrBlank((String)this.get("postalCode"))) {
errors.add("postalCode",
new ActionError("article1.postalCode.missing"));
}
if (nullOrBlank((String)this.get("phone"))) {
errors.add("phone", new ActionError("article1.phone.missing"));
}
return errors;
}

}
如果是这样,我们就要更改struts-config.xml来使用DynaActionForm的子类,这样的效果似乎是又回到了先前的样子(为每一个表单写DynaActionForm),呵呵。。。

所以推荐的做法是使用struts1.1种的Validator Framework,这方面的内容在以后的文章中在说明。


关于作者:

James Turner is the owner and manager of Black Bear Software, LLC, which specializes in custom Java-based e-Commerce and CRM solutions delivery. He is also the author of "MySQL and JSP Web Applications: Data-Driven Programming Using Tomcat and MySQL" (ISBN: 0672323095) and is the co-author of "Struts: Kick Start" (ISBN: 0672324725), which will be published in November. He can be reached at turner@blackbear.com.




关键词:Struts的动态表单的应用




Copyright © 2012-2018 盾怪网教程(http://www.dunguai.com) .All Rights Reserved 网站地图 友情链接

免责声明:本站资源均来自互联网收集 如有侵犯到您利益的地方请及时联系管理删除,敬请见谅!

QQ:1006262270   邮箱:kfyvi376850063@126.com   手机版