Struts 2 Annotations 用于对象、Arraylist、Arrays 的服务器端验证 [英] Struts 2 Anotations for Serverside validations of Objects, Arraylist,Arrays

查看:19
本文介绍了Struts 2 Annotations 用于对象、Arraylist、Arrays 的服务器端验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用 Struts2 提供的默认注解对数组、Arraylist、Objects 进行服务器端验证?

Is it possible to do server side validations for arrays,Arraylist,Objects using the default annotations provided by Struts2?

推荐答案

当然需要使用访问者字段验证器.

很久以前我写过一些关于使用它的东西(在 XML 中)这里;

Long time ago I've written something about using it (in XML) here;

基本上,您为 ONE 对象(或行")编写验证规则,并告诉 Action 使用访问者验证器验证该对象;如果您发送一个包含 100 个对象的数组或列表(从 JSP 到 Action),则每个对象都将通过放置(或注释)在声明对象的包中的访问者验证器进行验证,而不是在 Action 中包.

Basically, you write validation rules for ONE object (or "Row"), and you tell the Action to validate that object with Visitor Validator; if you send an array or a list of 100 objects (from the JSP to the Action), each of them will be validated through the visitor validator that is placed (or annotated) in the package where the object is declared, not in the Action package.

这篇关于Struts 2 Annotations 用于对象、Arraylist、Arrays 的服务器端验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆