Struts 配置

  <?xml version="1.0" encoding="UTF-8" ?>
  <!DOCTYPE struts-config (View Source for full doctype...)>
- < struts-config >
  < data-sources />
- < form-beans >
  < form-bean name =" userForm " type =" user.UserForm " />
  < form-bean name =" cardForm " type =" card.CardForm " />
  </ form-beans >
  < global-exceptions />
  < global-forwards />
- < action-mappings >
- < action attribute =" userForm " input =" /login.jsp " name =" userForm " path =" /user " scope =" request " type =" user.UserAction " validate =" false ">
  < forward name =" mainPage " path =" /main.jsp " />
  < forward name =" Login " path =" /login.jsp " />
  </ action >
- < action attribute =" cardForm " input =" /card/insert.jsp " name =" cardForm " path =" /card " scope =" request " type =" card.CardAction " validate =" false ">
  < forward name =" queryPage " path =" /card/query.jsp " />
  < forward name =" Login " path =" /login.jsp " />
  </ action >
  </ action-mappings >
  < message-resources parameter =" card.ApplicationResources " />
  </ struts-config >
  <?xml version="1.0" encoding="UTF-8" ?>
- < web-app xmlns =" http://java.sun.com/xml/ns/j2ee " xmlns:xsi =" http://www.w3.org/2001/XMLSchema-instance " version =" 2.4 " xsi:schemaLocation =" http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd ">
- < servlet >
  < servlet-name > action </ servlet-name >
  < servlet-class > org.apache.struts.action.ActionServlet </ servlet-class >
- < init-param >
  < param-name > config </ param-name >
  < param-value > /WEB-INF/struts-config.xml </ param-value >
  </ init-param >
- < init-param >
  < param-name > debug </ param-name >
  < param-value > 3 </ param-value >
  </ init-param >
- < init-param >
  < param-name > detail </ param-name >
  < param-value > 3 </ param-value >
  </ init-param >
  < load-on-startup > 0 </ load-on-startup >
  </ servlet >
- < servlet-mapping >
  < servlet-name > action </ servlet-name >
  < url-pattern > *.do </ url-pattern >
  </ servlet-mapping >
  </ web-app >
  <!DOCTYPE form-validation (View Source for full doctype...)>
- <!--
   This file contains the default Struts Validator pluggable validator
   definitions.  It should be placed somewhere under /WEB-INF and
   referenced in the struts-config.xml under the plug-in element
   for the ValidatorPlugIn.

      <plug-in className="org.apache.struts.validator.ValidatorPlugIn">
        <set-property property="pathnames" value="/WEB-INF/validator-rules.xml,
                                                  /WEB-INF/validation.xml"/>
      </plug-in>

   These are the default error messages associated with
   each validator defined in this file.  They should be
   added to your projects ApplicationResources.properties
   file or you can associate new ones by modifying the
   pluggable validators msg attributes in this file.

   # Struts Validator Error Messages
   errors.required={0} is required.
   errors.minlength={0} can not be less than {1} characters.
   errors.maxlength={0} can not be greater than {1} characters.
   errors.invalid={0} is invalid.

   errors.byte={0} must be a byte.
   errors.short={0} must be a short.
   errors.integer={0} must be an integer.
   errors.long={0} must be a long.
   errors.float={0} must be a float.
   errors.double={0} must be a double.

   errors.date={0} is not a date.
   errors.range={0} is not in the range {1} through {2}.
   errors.creditcard={0} is an invalid credit card number.
   errors.email={0} is an invalid e-mail address.

  --> <script></script>
- < form-validation >
- < global >
- < 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 ">
- < javascript >
- <![CDATA[
            function validateRequired(form) {
                var isValid = true;
                var focusField = null;
                var i = 0;
                var fields = new Array();
                oRequired = new required();
                for (x in oRequired) {
                	var field = form[oRequired[x][0]];
                	
                    if (field.type == 'text' ||
                        field.type == 'textarea' ||
                        field.type == 'file' ||
                        field.type == 'select-one' ||
                        field.type == 'radio' ||
                        field.type == 'password') {
                        
                        var value = '';
						// get field's value
						if (field.type == "select-one") {
							var si = field.selectedIndex;
							if (si >= 0) {
								value = field.options[si].value;
							}
						} else {
							value = field.value;
						}
                        
                        if (trim(value).length == 0) {
                        
	                        if (i == 0) {
	                            focusField = field;
	                        }
	                        fields[i++] = oRequired[x][1];
	                        isValid = false;
                        }
                    }
                }
                if (fields.length > 0) {
                   focusField.focus();
                   alert(fields.join('\n'));
                }
                return isValid;
            }
            
            // Trim whitespace from left and right sides of s.
            function trim(s) {
                return s.replace( /^\s*/, "" ).replace( /\s*$/, "" );
            }
            
            
  ]]> <script></script>
  </ javascript >
  </ validator >
  < validator name =" requiredif " classname =" org.apache.struts.validator.FieldChecks " method =" validateRequiredIf " methodParams =" java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionErrors, org.apache.commons.validator.Validator, javax.servlet.http.HttpServletRequest " msg =" errors.required " />
- < validator name =" minlength " classname =" org.apache.struts.validator.FieldChecks " method =" validateMinLength " methodParams =" java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionErrors, javax.servlet.http.HttpServletRequest " depends ="" msg =" errors.minlength ">
- < javascript >
- <![CDATA[
            function validateMinLength(form) {
                var isValid = true;
                var focusField = null;
                var i = 0;
                var fields = new Array();
                oMinLength = new minlength();
                for (x in oMinLength) {
                    var field = form[oMinLength[x][0]];
                    
                    if (field.type == 'text' ||
                        field.type == 'textarea') {
                        
                        var iMin = parseInt(oMinLength[x][2]("minlength"));
                        if ((trim(field.value).length > 0) && (field.value.length < iMin)) {
                            if (i == 0) {
                                focusField = field;
                            }
                            fields[i++] = oMinLength[x][1];
                            isValid = false;
                        }
                    }
                }
                if (fields.length > 0) {
                   focusField.focus();
                   alert(fields.join('\n'));
                }
                return isValid;
            }
  ]]> <script></script>
  </ javascript >
  </ validator >
- < validator name =" maxlength " classname =" org.apache.struts.validator.FieldChecks " method =" validateMaxLength " methodParams =" java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionErrors, javax.servlet.http.HttpServletRequest " depends ="" msg =" errors.maxlength ">
- < javascript >
- <![CDATA[
            function validateMaxLength(form) {
                var isValid = true;
                var focusField = null;
                var i = 0;
                var fields = new Array();
                oMaxLength = new maxlength();
                for (x in oMaxLength) {
                    var field = form[oMaxLength[x][0]];
                    
                    if (field.type == 'text' ||
                        field.type == 'textarea') {
                        
                        var iMax = parseInt(oMaxLength[x][2]("maxlength"));
                        if (field.value.length > iMax) {
                            if (i == 0) {
                                focusField = field;
                            }
                            fields[i++] = oMaxLength[x][1];
                            isValid = false;
                        }
                    }
                }
                if (fields.length > 0) {
                   focusField.focus();
                   alert(fields.join('\n'));
                }
                return isValid;
            }
  ]]> <script></script>
  </ javascript >
  </ validator >
- < 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 " depends ="" msg =" errors.invalid ">
- < javascript >
- <![CDATA[
            function validateMask(form) {
                var isValid = true;
                var focusField = null;
                var i = 0;
                var fields = new Array();
                oMasked = new mask();
                for (x in oMasked) {
                    var field = form[oMasked[x][0]];
                    
                    if ((field.type == 'text' || 
                         field.type == 'textarea') && 
                         (field.value.length > 0)) {
                        
                        if (!matchPattern(field.value, oMasked[x][2]("mask"))) {
                            if (i == 0) {
                                focusField = field;
                            }
                            fields[i++] = oMasked[x][1];
                            isValid = false;
                        }
                    }
                }
                
                if (fields.length > 0) {
                   focusField.focus();
                   alert(fields.join('\n'));
                }
                return isValid;
            }

            function matchPattern(value, mask) {
               return mask.exec(value);
            }
  ]]> <script></script>
  </ javascript >
  </ validator >
- < validator name =" byte " classname =" org.apache.struts.validator.FieldChecks " method =" validateByte " methodParams =" java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionErrors, javax.servlet.http.HttpServletRequest " depends ="" msg =" errors.byte " jsFunctionName =" ByteValidations ">
- < javascript >
- <![CDATA[
            function validateByte(form) {
                var bValid = true;
                var focusField = null;
                var i = 0;
                var fields = new Array();
                oByte = new ByteValidations();
                for (x in oByte) {
                	var field = form[oByte[x][0]];
                	
                    if (field.type == 'text' ||
                        field.type == 'textarea' ||
                        field.type == 'select-one' ||
						field.type == 'radio') {

						var value = '';
						// get field's value
						if (field.type == "select-one") {
							var si = field.selectedIndex;
							if (si >= 0) {
								value = field.options[si].value;
							}
						} else {
							value = field.value;
						}
                        
                        if (value.length > 0) {
                            if (!isAllDigits(value)) {
                                bValid = false;
                                if (i == 0) {
                                    focusField = field;
                                }
                                fields[i++] = oByte[x][1];

                            } else {

	                            var iValue = parseInt(value);
	                            if (isNaN(iValue) || !(iValue >= -128 && iValue <= 127)) {
	                                if (i == 0) {
	                                    focusField = field;
	                                }
	                                fields[i++] = oByte[x][1];
	                                bValid = false;
	                            }
                            }
						}
						
                    }
                }
                if (fields.length > 0) {
                   focusField.focus();
                   alert(fields.join('\n'));
                }
                return bValid;
            }
  ]]> <script></script>
  </ javascript >
  </ validator >
- < validator name =" short " classname =" org.apache.struts.validator.FieldChecks " method =" validateShort " methodParams =" java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionErrors, javax.servlet.http.HttpServletRequest " depends ="" msg =" errors.short " jsFunctionName =" ShortValidations ">
- < javascript >
- <![CDATA[
            function validateShort(form) {
                var bValid = true;
                var focusField = null;
                var i = 0;
                var fields = new Array();
                oShort = new ShortValidations();
                for (x in oShort) {
                	var field = form[oShort[x][0]];
                	
                    if (field.type == 'text' ||
                        field.type == 'textarea' ||
                        field.type == 'select-one' ||
                        field.type == 'radio') {
                        
                        var value = '';
						// get field's value
						if (field.type == "select-one") {
							var si = field.selectedIndex;
							if (si >= 0) {
								value = field.options[si].value;
							}
						} else {
							value = field.value;
						}
                        
                        if (value.length > 0) {
                            if (!isAllDigits(value)) {
                                bValid = false;
                                if (i == 0) {
                                    focusField = field;
                                }
                                fields[i++] = oShort[x][1];

                            } else {
                        
	                            var iValue = parseInt(value);
	                            if (isNaN(iValue) || !(iValue >= -32768 && iValue <= 32767)) {
	                                if (i == 0) {
	                                    focusField = field;
	                                }
	                                fields[i++] = oShort[x][1];
	                                bValid = false;
	                            }
	                       }
                       }
                    }
                }
                if (fields.length > 0) {
                   focusField.focus();
                   alert(fields.join('\n'));
                }
                return bValid;
            }
  ]]> <script></script>
  </ javascript >
  </ validator >
- < validator name =" integer " classname =" org.apache.struts.validator.FieldChecks " method =" validateInteger " methodParams =" java.lang.Object, org.apache.commons.validator.ValidatorAction, org.apache.commons.validator.Field, org.apache.struts.action.ActionErrors, javax.servlet.http.HttpServletRequest " depends ="" msg =" errors.integer " jsFunctionName =" IntegerValida

你可能感兴趣的:(JavaScript,apache,jsp,struts,servlet)