- 浏览: 30776 次
- 性别:
- 来自: 上海
最新评论
-
halk:
H在哪??文不对题啊
SSH2.0 -
miaozilong:
哪儿有的下载的
SSH2.0 -
guixian:
那你后来跟他们的客户见面了吗?没给你结果吗?
有谁知道上海神州数码融信软件公司的情况啊? -
programmedbloke:
呵呵 ,我现在换了一家单位。
有谁知道上海神州数码融信软件公司的情况啊? -
guixian:
我现在遇到跟你一样的情况,你最后的结果咋样了?呵呵,盼回!
有谁知道上海神州数码融信软件公司的情况啊?
Struts Validator Guide
Struts Validator
The Struts Validator, in some form, has been available since the days of Struts 0.5. It was orignally packaged as a developer contribution. Later, the core code was moved to the Jakarta Commons and a Struts specific extension became part of Struts since 1.1.
For the convenience of the many developers who have been using the Struts Validator all along, this document first overviews the core functionality and then covers the changes and new functionality added since Struts 1.1.
Once you have configured the Validator Plug-In, so that it can load your Validator Resources you just have to extend
org.apache.struts.validator.action.ValidatorForm
instead of
org.apache.struts.action.ActionForm
. Then when the
validate
method is called, the action's name attribute from the Struts Configuration is used to load the validations for the current form. The form element's
name
attribute in the Validator configuration should match the action element's
name
attribute.
An alternative approach is to use the action mapping path attribute. In this case, you extend the ValidatorActionForm instead of the ValidatorForm. The ValidatorActionForm uses the action element's
path
attribute from the Struts configuration which should match the form element's
name
attribute in the Validator configuration.
Then a separate action mapping can be defined for each page in a multi-page form, and the validation form can be associated with the action rather than a page number (as shown in the example of a multi-page form in the validator example).
Internationalization
Each validator form is grouped within a
FormSet
element in the Validator configuration file. The
FormSet
has language, country, and variant attributes that correspond with the
java.util.Locale
class. If these attributes are not specified, the
FormSet
will be set to the default locale. A
FormSet
can also have constants associated with it. On the same level as a
FormSet
there can be a global element which can also have constants and have validator actions that perform validations.
Note: You must declare a default
FormSet
without internationalization before your internationalized
FormSet
s. This allows the Validator to fall back to the default version if no locale is found.
The default error message for a pluggable validator can be overriden with the
msg
element. So instead of using the
msg
attribute for the mask validator to generate the error message the
msg
attribute from the field will be used if the name of the field's name attribute matches the validator's name attribute.
The arguments for error messages can be set with the arg0-arg3 elements. If the arg0-arg3 elements' name attribute isn't set, it will become the default arg value for the different error messages constructed. If the name attribute is set, you can specify the argument for a specific pluggable validator and then this will be used for constructing the error message.
<field property="lastName" depends="required,mask"> <msg name="mask" key="registrationForm.lastname.maskmsg"/> <arg0 key="registrationForm.lastname.displayname"/> <var> <var-name>mask</var-name> <var-value>^[a-zA-Z]*$</var-value> </var></field>
By default the arg0-arg3 elements will try to look up the
key
attribute in the message resources. If the resource attribute is set to false, it will pass in the value directly without retrieving the value from the message resources.
Note that since Struts 1.1, you must explicitly define your message resource in any module that is going to use the Validator, due to a problem accessing the top-level resource. This only effects applications which are using modules.
<field property="integer" depends="required,integer,intRange"> <arg0 key="typeForm.integer.displayname"/> <arg1 name="intRange" key="${var:min}" resource="false"/> <arg2 name="intRange" key="${var:max}" resource="false"/> <var> <var-name>min</var-name> <var-value>10</var-value> </var> <var> <var-name>max</var-name> <var-value>20</var-value> </var> </field>
Standard Built In Validations
Validator ships with a set of pre-defined validators, as follows:
- required - mandatory field validation. Has no variables.
<field property="name" depends="required"> <arg0 key="customer.name"/> </field>
- requiredif - field dependant validator
Deprecated, use validwhen.
- validwhen - validator for checking one field against another.
see later section titled Designing "Complex Validations with validwhen".
- minlength - validate input data isn't less than a specified minimum length. Requires a
minlength
variable.
<field property="name" depends="required,minlength"> <arg0 key="customer.name"/> <arg1 name="minlength" key="${var:minlength}" resource="false"/> <var><var-name>minlength</var-name><var-value>3</var-value></var> </field>
- maxlength - validate input data doesn't exceed a specified maximum length. Requires a
maxlength
variable.
<field property="name" depends="required,maxlength"> <arg0 key="customer.name"/> <arg1 name="maxlength" key="${var:maxlength}" resource="false"/> <var><var-name>maxlength</var-name><var-value>30</var-value></var> </field>
- mask - validate format according to a regular expression. Requires a
mask
variable to specify the regular expression. Since version 1.1, the regular expression must start with a
^
and end with a
$
(see example below).
<field property="name" depends="required,mask"> <msg name="mask" key="registrationForm.lastname.maskmsg"/> <arg0 key="registration.name"/> <var><var-name>mask</var-name><var-value>^[a-zA-Z]*$</var-value></var> </field>
- byte - validates that a field can be converted to a Byte.
<field property="age" depends="byte"> <arg0 key="employee.age"/> </field>
- short - validates that a field can be converted to a Short.
<field property="productnumber" depends="short"> <arg0 key="order.prodno"/> </field>
- integer - validates that a field can be converted to an Integer.
<field property="ordernumber" depends="integer"> <arg0 key="order.number"/> </field>
- long - validates that a field can be converted to a Long.
<field property="ordernumber" depends="long"> <arg0 key="order.number"/> </field>
- float - validates that a field can be converted to a Float.
<field property="amount" depends="float"> <arg0 key="sale.amount"/> </field>
- double - validates that a field can be converted to a Double.
<field property="amount" depends="double"> <arg0 key="sale.amount"/> </field>
- date - validates that a field can be converted to a Date. This validator uses
java.text.SimpleDateFormat
to parse the date and optionally either a
datePattern
or
datePatternStrict
variable can be used. If no pattern is specified the default short date format is assumed. The difference between using the
datePatternStrict
and
datePattern
variables is that
datePatternStrict
checks additionally that the input data is the same length as the pattern specified (so for example 1/1/2004 would fail with a pattern of
MM/dd/yyyy
).
<field property="saledate" depends="required,date"> <arg0 key="myForm.saledate"/> <var><var-name>datePattern</var-name><var-value>MM/dd/yyyy</var-value></var> </field>
<field property="saledate" depends="required,date"> <arg0 key="sale.orderdate"/> <var><var-name>datePatternStrict</var-name><var-value>MM/dd/yyyy</var-value></var> </field>
- range - validate number range.
Deprecated, use intRange, floatRange or doubleRange.
- intRange - validates that an integer field is within a specified range. Requires
min
and
max
variables to specify the range. This validator depends on the
integer
validator which must also be in the field's
depends
attribute.
<field property="age" depends="required,integer,intRange"> <arg0 key="employee.age"/> <arg1 name="intRange" key="${var:min}" resource="false"/> <arg2 name="intRange" key="${var:max}" resource="false"/> <var><var-name>min</var-name><var-value>18</var-value></var> <var><var-name>max</var-name><var-value>65</var-value></var> </field>
- floatRange - validates that a float field is within a specified range Requires
min
and
max
variables to specify the range. This validator depends on the
float
validator which must also be in the field's
depends
attribute.
<field property="ordervalue" depends="required,float,floatRange"> <arg0 key="order.value"/> <arg1 name="floatRange" key="${var:min}" resource="false"/> <arg2 name="floatRange" key="${var:max}" resource="false"/> <var><var-name>min</var-name><var-value>100</var-value></var> <var><var-name>max</var-name><var-value>4.99</var-value></var> </field>
- doubleRange - validates that a double field is within a specified range Requires
min
and
max
variables to specify the range. This validator depends on the
double
validator which must also be in the field's
depends
attribute.
<field property="ordervalue" depends="required,double,doubleRange"> <arg0 key="employee.age"/> <arg1 name="doubleRange" key="${var:min}" resource="false"/> <arg2 name="doubleRange" key="${var:max}" resource="false"/> <var><var-name>min</var-name><var-value>100</var-value></var> <var><var-name>max</var-name><var-value>4.99</var-value></var> </field>
- creditCard - validate credit card number format
<field property="name" depends="required, creditCard"> <arg0 key="customer.cardnumber"/> </field>
- email - validate email address format
<field property="customeremail" depends="email"> <arg0 key="customer.email"/> </field>
- url - validates url format. Has four optional variables (
allowallschemes
,
allow2slashes
,
nofragments
and
schemes
) which can be used to configure this validator.
- allowallschemes specifies whether all schemes are allowed. Valid values are
true
or
false
(default is
false
). If this is set to
true
then the
schemes
variable is ignored.
- allow2slashes specifies whether double '/' characters are allowed. Valid values are
true
or
false
(default is
false
).
- nofragments specifies whether fragements are allowed. Valid values are
true
or
false
(default is
false
- i.e. fragments are allowed).
- schemes - use to specify a comma separated list of valid schemes. If not specified then the defaults are used which are
http
,
https
and
ftp
.
<field property="custUrl" depends="url"> <arg0 key="customer.url"/> </field> <field property="custUrl" depends="url"> <arg0 key="customer.url"/> <var> <var-name>nofragments</var-name> <var-value>true</var-value> </var> <var> <var-name>schemes</var-name> <var-value>http,https,telnet,file</var-value> </var> </field>
- allowallschemes specifies whether all schemes are allowed. Valid values are
Constants/Variables
Global constants can be inside the global tags and FormSet/Locale constants can be created in the formset tags. Constants are currently only replaced in the Field's property attribute, the Field's var element value attribute, the Field's msg element key attribute, and Field's arg0-arg3 element's key attribute. A Field's variables can also be substituted in the arg0-arg3 elements (ex: ${var:min}). The order of replacement is FormSet/Locale constants are replaced first, Global constants second, and for the arg elements variables are replaced last.
<global> <constant> <constant-name>zip</constant-name> <constant-value>^\d{5}(-\d{4})?$</constant-value> </constant></global><field property="zip" depends="required,mask"><arg0 key="registrationForm.zippostal.displayname"/><var> <var-name>mask</var-name> <var-value>${zip}</var-value></var></field>
The var element under a field can be used to store variables for use by a pluggable validator. These variables are available through the Field's
getVar(String key)
method.
<field property="integer" depends="required,integer,intRange"> <arg0 key="typeForm.integer.displayname"/> <arg1 name="intRange" key="${var:min}" resource="false"/> <arg2 name="intRange" key="${var:max}" resource="false"/> <var> <var-name>min</var-name> <var-value>10</var-value> </var> <var> <var-name>max</var-name> <var-value>20</var-value> </var> </field>
Designing Complex Validations with validwhen
[Since Struts 1.2.0] A frequent requirement in validation design is to validate one field against another (for example, if you have asked the user to type in a password twice for confirmation, to make sure that the values match.) In addition, there are fields in a form that may only be required if other fields have certain values. The
validwhen
validator is designed to handle these cases.
The
validwhen
validator takes a single
var
field, called
test
. The value of this var is a boolean expression which must be true in order for the validation to success. The values which are allowed in the expression are:
- Single or double-quoted string literals.
- Integer literals in decimal, hex or octal format
- The value
null
which will match against either null or an empty string
- Other fields in the form referenced by field name, such as
customerAge
- Indexed fields in the form referenced by an explicit integer, such as
childLastName[2]
- Indexed fields in the form referenced by an implicit integer, such as
childLastName[]
, which will use the same index into the array as the index of the field being tested.
- Properties of an indexed fields in the form referenced by an explicit or implicit integer, such as
child[].lastName
, which will use the same index into the array as the index of the field being tested.
- The literal
*this*
, which contains the value of the field currently being tested
As an example of how this would work, consider a form with fields
sendNewsletter
and
emailAddress
. The
emailAddress
field is only required if the
sendNewsletter
field is not null. You could code this using validwhen as:
<field property="emailAddress" depends="validwhen"> <arg0 key="userinfo.emailAddress.label"/> <var> <var-name>test</var-name> <var-value>((sendNewsletter == null) or (*this* != null))</var-value> </var> </field>
Which reads as: this field is valid if
sendNewsletter
is
null
or the field value is not
null
.
Here's a slightly more complicated example using indexed fields. Assume a form with a number of lines to allow the user to enter part numbers and quantities they wish to order. An array of beans of class
orderLine
is used to hold the entries in a property called orderLines. If you wished to verify that every line with part number also had a quantity entered, you could do it with:
<field property="quantity" indexedListProperty="orderLines" depends="validwhen"> <arg0 key="orderform.quantity.label"/> <var> <var-name>test</var-name> <var-value>((orderLines[].partNumber == null) or (*this* != null))</var-value> </var> </field>
Which reads as: This field is value if the corresponding
partNumber
field is
null
, or this field is not
null
.
As a final example, imagine a form where the user must enter their height in inches, and if they are under 60 inches in height, it is an error to have checked off nbaPointGuard as a career.
<field property="nbaPointGuard" depends="validwhen"> <arg0 key="careers.nbaPointGuard.label"/> <var> <var-name>test</var-name> <var-value>((heightInInches >= 60) or (*this* == null))</var-value> </var> </field>
A few quick notes on the grammer.
- All comparisons must be enclosed in parens.
- Only two items may be joined with
and
or
or
- If both items to be compared are convertable to ints, a numeric comparison is done, otherwise a string comparison is done.
Pluggable Validators
By convention, the validators your application uses can beloaded through a file named "validator-rules.xml", and the validator forms (or "validations") can be configured separately (say, in a "validations.xml" file). This approach separates the validators, that you might reuse in another application, from the validations that are specific to each application.
The Validator comes bundled with several ready-to-use validators. The bundled validators include: required, mask ,byte, short, int, long, float, double, date (without locale support), and a numeric range.
The 'mask' validator depends on 'required' in the default setup. That means that 'required' has to complete successfully before 'mask' will run. The 'required' and 'mask' validators are partially built into the framework. Any field that isn't 'required' will skip other validations if the field is null or has a length of zero. Regardless, the implementations of 'required' and 'mask' are still plugged in through the configuration file, like all the others.
If the Javascript Tag is used, the client side Javascript generation looks for a value in the validator's javascript attribute and generates an object that the supplied method can use to validate the form. For a more detailed explanation of how the Javascript Validator Tag works, see the html taglib API reference.
The 'mask' validator lets you validate a regular expression mask to the field. It uses the Regular Expression Package from the Apache Jakarta site.
The main class used is
org.apache.regexp.RE
.
Example Validator Configuration from the default validator-rules.xml.
<validator name="required" classname="org.apache.struts.validator.FieldChecks" method="validateRequired" methodParams="java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionErrors, javax.servlet.http.HttpServletRequest" msg="errors.required"><validator name="mask" classname="org.apache.struts.validator.FieldChecks" method="validateMask" methodParams="java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionErrors, javax.servlet.http.HttpServletRequest" msg="errors.invalid">
Creating Pluggable Validators
The
methodParams
attribute takes a comma separated list of class names. The
method
attribute needs to have a signature complying with the above list. The list can be comprised of any combination of the following:
-
java.lang.Object
- Bean validation is being performed on.
-
org.apache.commons.validator.ValidatorAction
- The current ValidatorAction being performed.
-
org.apache.commons.validator.Field
- Field object being validated.
-
org.apache.struts.action.ActionErrors
- The errors objects to add an ActionError to if the validation fails.
-
javax.servlet.http.HttpServletRequest
- Current request object.
-
javax.servlet.ServletContext
- The application's ServletContext.
-
org.apache.commons.validator.Validator
- The current org.apache.commons.validator.Validator instance.
-
java.util.Locale
- The Locale of the current user.
Multi Page Forms
The field element has an optional page attribute. It can be set to an integer. All validation for any field on a page less than or equal to the current page is performed server side. All validation for any field on a page equal to the current page is generated for the client side Javascript. A mutli-part form expects the page attribute to be set.
<html:hidden property="page" value="1"/>
Comparing Two Fields
This is an example of how you could compare two fields to see if they have the same value. A good example of this is when you are validating a user changing their password and there is the main password field and a confirmation field.
<validator name="twofields" classname="com.mysite.StrutsValidator" method="validateTwoFields" msg="errors.twofields"/><field property="password" depends="required,twofields"> <arg0 key="typeForm.password.displayname"/> <var> <var-name>secondProperty</var-name> <var-value>password2</var-value> </var></field>
public static boolean validateTwoFields( Object bean, ValidatorAction va, Field field, ActionErrors errors, HttpServletRequest request, ServletContext application) { String value = ValidatorUtils.getValueAsString( bean, field.getProperty()); String sProperty2 = field.getVarValue("secondProperty"); String value2 = ValidatorUtils.getValueAsString( bean, sProperty2); if (!GenericValidator.isBlankOrNull(value)) { try { if (!value.equals(value2)) { errors.add(field.getKey(), Resources.getActionError( application, request, va, field)); return false; } } catch (Exception e) { errors.add(field.getKey(), Resources.getActionError( application, request, va, field)); return false; } } return true;}
Known Bugs
Since the Struts Validator relies on the Commons Validator, problem reports and enhancement requests may be listed against either product.
Conditionally required fields
You can define logic like "only validate this field if field X is non-null and field Y equals 'male'". The recommended way to do this will be with the
validwhen
validator, described above, and available since Struts 1.2.0. The
requiredif
validator, which was added since Struts 1.1, will be deprecated in favor of
validwhen
, and
requiredif
will be removed in a future release. However, if you are using
requiredif
, here is a brief tutorial.
Let's assume you have a medical information form with three fields, sex, pregnancyTest, and testResult. If sex is 'f' or 'F', pregnancyTest is required. If pregnancyTest is not blank, testResult is required. The entry in your Validator configuration would look like this:
<form name="medicalStatusForm"><field property="pregnancyTest" depends="requiredif"> <arg0 key="medicalStatusForm.pregnancyTest.label"/> <var> <var-name>field[0]</var-name> <var-value>sex</var-value> </var> <var> <var-name>fieldTest[0]</var-name> <var-value>EQUAL</var-value> </var> <var> <var-name>fieldValue[0]</var-name> <var-value>F</var-value> </var> <var> <var-name>field[1]</var-name> <var-value>sex</var-value> </var> <var> <var-name>fieldTest[1]</var-name> <var-value>EQUAL</var-value> </var> <var> <var-name>fieldValue[1]</var-name> <var-value>f</var-value> </var> <var> <var-name>fieldJoin</var-name> <var-value>OR</var-value> </var></field><field property="testResult" depends="requiredif"> <arg0 key="medicalStatusForm.testResult.label"/> <var> <var-name>field[0]</var-name> <var-value>pregnancyTest</var-value> </var> <var> <var-name>fieldTest[0]</var-name> <var-value>NOTNULL</var-value> </var></field></form>
Here's a more complex example using indexed properties.
If you have this in your Struts configuration
<form-bean name="dependentlistForm" type="org.apache.struts.webapp.validator.forms.ValidatorForm"> <form-property name="dependents" type="org.apache.struts.webapp.validator.Dependent[]" size="10"/> <form-property name="insureDependents" type="java.lang.Boolean" initial="false"/></form-bean>
Where dependent is a bean that has properties lastName, firstName, dob, coverageType
You can define a validation:
<form name="dependentlistForm"><field property="firstName" indexedListProperty="dependents" depends="requiredif"> <arg0 key="dependentlistForm.firstName.label"/> <var> <var-name>field[0]</var-name> <var-value>lastName</var-value> </var> <var> <var-name>fieldIndexed[0]</var-name> <var-value>true</var-value> </var> <var> <var-name>fieldTest[0]</var-name> <var-value>NOTNULL</var-value> </var></field><field property="dob" indexedListProperty="dependents" depends="requiredif,date"> <arg0 key="dependentlistForm.dob.label"/> <var> <var-name>field[0]</var-name> <var-value>lastName</var-value> </var> <var> <var-name>fieldIndexed[0]</var-name> <var-value>true</var-value> </var> <var> <var-name>fieldTest[0]</var-name> <var-value>NOTNULL</var-value> </var></field><field property="coverageType" indexedListProperty="dependents" depends="requiredif"> <arg0 key="dependentlistForm.coverageType.label"/> <var> <var-name>field[0]</var-name> <var-value>lastName</var-value> </var> <var> <var-name>fieldIndexed[0]</var-name> <var-value>true</var-value> </var> <var> <var-name>fieldTest[0]</var-name> <var-value>NOTNULL</var-value> </var> <var> <var-name>field[1]</var-name> <var-value>insureDependents</var-value> </var> <var> <var-name>fieldTest[1]</var-name> <var-value>EQUAL</var-value> </var> <var> <var-name>fieldValue[1]</var-name> <var-value>true</var-value> </var> <var> <var-name>fieldJoin</var-name> <var-value>AND</var-value> </var></field></form>
Which is read as follows: The firstName field is only required if the lastName field is non-null. Since fieldIndexed is true, it means that lastName must be a property of the same indexed field as firstName. Same thing for dob, except that we validate for date if not blank.
The coverageType is only required if the lastName for the same indexed bean is not null, and also if the non-indexed field insureDependents is true.
You can have an arbitrary number of fields by using the [n] syntax, the only restriction is that they must all be AND or OR, you can't mix.
Unstoppable JavaScript Validations
[Since Struts 1.2.0] You can force the clientside Javascript validation to check all constraints, instead of stopping at the first error. By setting a new property,
stopOnFirstError
, on the Validator PlugIn to false.
Here's a sample configuration block that you could use in your Struts configuration file:
<plug-in className="org.apache.struts.validator.ValidatorPlugIn"> <set-property property="pathnames" value="/WEB-INF/validator-rules.xml,/WEB-INF/validations.xml"/> <set-property property="stopOnFirstError" value="false"/> </plug-in>
发表评论
-
spring声明式事务管理
2008-11-19 22:17 1048通常建议采用声明式事务管理。声明式事务管理的优势非常明显:代码 ... -
SQLserver中用convert函数转换日期格式
2008-11-19 22:12 3732SQLserver中用convert函数转换日期格式 2008 ... -
spring在websphere服务器中的问题
2008-11-19 22:09 1334现在在用websphere服务器,在服务器启动时spr ... -
有用的正则表达式
2008-11-19 22:03 654正则表达式 匹配中文字符的正则表达式: [\u4e00-\u ... -
什么是SNS网站
2008-11-19 22:02 758SNS:Social Network Sofwaret,社会性 ... -
介绍 JSON
2008-11-19 22:01 1430JSON(JavaScript Object Notation ... -
用 JSON 处理缓存
2008-11-19 21:59 1176数据验证是每个企业 Web ... -
给Java中的List排序
2008-11-19 21:52 1202//java list 排序 //关键词: java ... -
java生成MD5编码
2008-10-05 18:42 1270MD5即Message-Digest Algorithm 5( ... -
java 交类
2008-04-01 22:50 588各位,谁知道Java中交类的概念啊,能给讲讲吗?郁闷,这是一个 ... -
ssh 报 could not inspect JDBC autocommit mode
2007-11-08 22:45 2019这几天做SSH时,在刷新页面和多次跳转时经常报一个异常,如下: ...
相关推荐
### Struts Validator 验证框架详细讲解 #### 引言 在Java Web开发中,数据验证是确保应用程序安全性和用户体验的重要环节。Struts框架作为早期流行的MVC框架之一,提供了强大的验证机制——Struts Validator,它...
Struts Validator是一个强大的验证框架,它是Apache Struts框架的一部分,用于在Java Web应用程序中实现数据输入验证。这个项目集成了验证规则,使得开发者能够轻松地确保用户提交的数据符合预期的格式和约束,从而...
### Struts Validator 验证器使用指南:深入解析与实践 #### 一、Struts Validator 简介 Struts Validator框架是Struts框架的重要组成部分,用于实现客户端和服务器端的数据验证。自0.5版以来,Struts Validator就...
Struts Validator框架是Apache Struts框架的一个重要组成部分,由IBM公司提供支持,它主要用于Web应用程序中的数据验证。这个框架提供了一种结构化的方式来定义和执行客户端及服务器端的数据验证规则,确保用户输入...
Struts Validator 是 Apache Struts 框架的一个重要组成部分,它提供了一种方便的方式来验证用户输入数据的有效性。Struts 通过插件(Plugin)机制来集成 Validator 功能,使得开发者可以轻松地在应用中添加数据验证...
Struts Validator是Apache Struts框架的一个重要组成部分,用于在服务器端进行数据验证。它提供了一种灵活且可扩展的方式来确保用户提交的数据满足应用程序设定的规则和格式,从而提高应用程序的安全性和用户体验。...
struts中自定义validator验证 <br>很多时候需要验证“密码”与“重复密码”是否一致,如果放在服务器端验证就浪费资源了。 如何在客户端进行验证...JS可以实现,但是struts的validator框架是否能实现呢?-见示例
Struts Validator是一个在Java Web开发中广泛使用的框架,主要用于处理用户输入验证。它与Apache Struts框架紧密结合,提供了一种规范化的验证机制,确保应用程序接收到的数据是合法且符合业务规则的。Struts ...
Struts的Validator-rules是Apache Struts框架的一个关键组件,主要用于处理Web应用中的表单验证。这个组件使得开发者能够方便地定义和实现客户端与服务器端的数据验证规则,从而确保用户输入的数据符合业务逻辑的...
Struts Validator框架是Apache Struts框架的一个重要组成部分,主要用于处理Web表单验证。它提供了一种声明式的方式来定义验证规则,使得开发者可以集中精力在业务逻辑上,而不是编写复杂的验证代码。Validator框架...
Struts是Java Web开发中的一个流行MVC框架,它的核心组件之一是Validator,用于处理表单数据的验证。本文将详细介绍Struts验证器Validator的使用,包括基础配置、自定义验证器的创建,以及如何在Maven项目中管理和...
Struts Validator是一个强大的验证框架,它是Apache Struts框架的一部分,用于在Java Web应用程序中实现数据验证。这个框架帮助开发者在用户提交表单时确保输入的数据是合法、完整且符合业务规则的,从而提高应用...
Struts Validator是一个强大的验证框架,它是Apache Struts项目的一部分,专为Java Web应用程序设计,用于实现数据输入验证。Struts框架本身是一个MVC(模型-视图-控制器)架构,而Validator则是它的一个核心组件,...
Struts的Validator框架是Java Web开发中用于处理用户输入验证的一种强大的工具,它与MVC架构中的控制器层紧密结合,提供了一种便捷的方式来确保用户提交的数据符合预设的业务规则。这个框架大大简化了数据验证的过程...
Struts Validator是一个强大的工具,用于在Struts框架中执行客户端和服务器端的数据验证。这个验证器自Struts 1.1版本开始成为其核心组成部分,极大地增强了应用的健壮性和用户体验。以下是对Struts Validator使用的...
Struts Validator是一个强大的验证框架,它是Apache Struts项目的一部分,用于在Java Web应用程序中执行客户端和服务器端的数据验证。这个“一个validator的验证程序.rar_struts_validator”压缩包包含了一个作者自...
Validator框架是Struts的一个重要组件,主要负责处理用户输入的数据验证,确保数据的完整性和正确性。在本文中,我们将深入探讨如何在Struts中使用Validator框架,并通过三个逐步进阶的实例来理解其工作原理。 首先...