文档章节

struts+spring+hibernate的web应用【10】

ruyees
 ruyees
发布于 2014/10/05 11:47
字数 3410
阅读 6
收藏 0
点赞 0
评论 0

 

第二十五部分:在同个目录下,添加 validator-rules.xml ,这个在 struts 开发包中有,只需要 copy 过来就

               可以用了。为了方便大家,我这里将里面配置代码粘贴出来:

 

<? xml version="1.0" encoding="ISO-8859-1"  ?> 
 <! DOCTYPE form-validation PUBLIC
          "-//Apache Software Foundation//DTD Commons Validator Rules Configuration 1.0//EN"
          "http://jakarta.apache.org/commons/dtds/validator_1_0.dtd" > 
 <!-- 
 
   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.

 --> 
 
 < 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' ||
                        field.type == 'hidden') {
                        
                        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) {
                  if(focusField.type!='hidden'){
                   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*$/, "" );
            }
            
             ]]>   </ javascript > 
         </ validator > 
         <!-- 
          Åжϸ´Ñ¡¿ò²»ÄÜΪ¿Õ
          ÕÔÆ·º£  2004
           --> 
         < 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" > 
             < javascript > <![CDATA[ 
            function validateRequiredIf(form) {
                var isValid = true;
                var focusField = null;
                var i = 0;
                var fields = new Array();
                var j=0;
                oRequiredif = new requiredif();
                for (x in oRequiredif) {
                    var field = form[oRequiredif[x][0]];
                    for(var ii=0;ii<field.length;ii++){
                        if(field[ii].checked==true){
                            j++;
                        }
                    }  
                     if (j == 0) {
                        
                            if (i == 0) {
                                focusField = field;
                            }
                            fields[i++] = oRequiredif[x][1];
                            isValid = false;
                    }
                }

                if (fields.length > 0) {
                   alert(fields.join('\n'));
                }
                return isValid;
            }
             ]]>   </ javascript > 
         </ validator > 
         < 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'||
                        field.type == 'password') {
                        
                        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;
            } ]]>   </ 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'||
                        field.type == 'password') {
                        
                        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;
            } ]]>   </ 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.type == 'password') && 
                         (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);
            } ]]>   </ 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;
            } ]]>   </ 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;
            } ]]>   </ 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 ="IntegerValidations" > 
             < javascript > <![CDATA[ 
            function validateInteger(form) {
                var bValid = true;
                var focusField = null;
                var i = 0;
                var fields = new Array();
                oInteger = new IntegerValidations();
                for (x in oInteger) {
                    var field = form[oInteger[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++] = oInteger[x][1];
                                
                            } else {
                                var iValue = parseInt(value);
                                if (isNaN(iValue) || !(iValue >= -2147483648 && iValue <= 2147483647)) {
                                    if (i == 0) {
                                        focusField = field;
                                    }
                                    fields[i++] = oInteger[x][1];
                                    bValid = false;
                               }
                           }
                       }
                    }
                }
                if (fields.length > 0) {
                   focusField.focus();
                   alert(fields.join('\n'));
                }
                return bValid;
            }

            function isAllDigits(argvalue) {
                argvalue = argvalue.toString();
                var validChars = "0123456789";
                var startFrom = 0;
                if (argvalue.substring(0, 2) == "0x") {
                   validChars = "0123456789abcdefABCDEF";
                   startFrom = 2;
                } else if (argvalue.charAt(0) == "-") {
                    startFrom = 1;
                }
                
                for (var n = startFrom; n < argvalue.length; n++) {
                    if (validChars.indexOf(argvalue.substring(n, n+1)) == -1) return false;
                }
                return true;
            } ]]>   </ javascript > 
         </ validator > 
         < validator  name ="long"  
            classname ="org.apache.struts.validator.FieldChecks"  
            method ="validateLong"  
            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.long" /> 
         < validator  name ="float"  
            classname ="org.apache.struts.validator.FieldChecks"  
            method ="validateFloat"  
            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.float"  jsFunctionName ="FloatValidations" > 
             < javascript > <![CDATA[ 
            function validateFloat(form) {
                var bValid = true;
                var focusField = null;
                var i = 0;
                var fields = new Array();
                oFloat = new FloatValidations();
                for (x in oFloat) {
                    var field = form[oFloat[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) {
                            // remove '.' before checking digits
                            var tempArray = value.split('.');
                            var joinedString= tempArray.join('');

                            if (!isAllDigits(joinedString)) {
                                bValid = false;
                                if (i == 0) {
                                    focusField = field;
                                }
                                fields[i++] = oFloat[x][1];

                            } else {
                                var iValue = parseFloat(value);
                                if (isNaN(iValue)) {
                                    if (i == 0) {
                                        focusField = field;
                                    }
                                    fields[i++] = oFloat[x][1];
                                    bValid = false;
                                }
                            }
                        }
                    }
                }
                if (fields.length > 0) {
                   focusField.focus();
                   alert(fields.join('\n'));
                }
                return bValid;
            } ]]>   </ javascript > 
         </ validator > 
         < validator  name ="double"  
            classname ="org.apache.struts.validator.FieldChecks"  
            method ="validateDouble"  
            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.double" /> 
         < validator  name ="date"  
            classname ="org.apache.struts.validator.FieldChecks"  
            method ="validateDate"  
            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.date"  jsFunctionName ="DateValidations" > 
             < javascript > <![CDATA[ 
            function validateDate(form) {
               var bValid = true;
               var focusField = null;
               var i = 0;
               var fields = new Array();
               oDate = new DateValidations();
               for (x in oDate) {
                   var value = form[oDate[x][0]].value;
                   var datePattern = oDate[x][2]("datePatternStrict");
                   if ((form[oDate[x][0]].type == 'text' ||
                        form[oDate[x][0]].type == 'textarea') &&
                       (value.length > 0) &&
                       (datePattern.length > 0)) {
                     var MONTH = "MM";
                     var DAY = "dd";
                     var YEAR = "yyyy";
                     var orderMonth = datePattern.indexOf(MONTH);
                     var orderDay = datePattern.indexOf(DAY);
                     var orderYear = datePattern.indexOf(YEAR);
                     if ((orderDay < orderYear && orderDay > orderMonth)) {
                         var iDelim1 = orderMonth + MONTH.length;
                         var iDelim2 = orderDay + DAY.length;
                         var delim1 = datePattern.substring(iDelim1, iDelim1 + 1);
                         var delim2 = datePattern.substring(iDelim2, iDelim2 + 1);
                         if (iDelim1 == orderDay && iDelim2 == orderYear) {
                            dateRegexp = new RegExp("^(\\d{2})(\\d{2})(\\d{4})$");
                         } else if (iDelim1 == orderDay) {
                            dateRegexp = new RegExp("^(\\d{2})(\\d{2})[" + delim2 + "](\\d{4})$");
                         } else if (iDelim2 == orderYear) {
                            dateRegexp = new RegExp("^(\\d{2})[" + delim1 + "](\\d{2})(\\d{4})$");
                         } else {
                            dateRegexp = new RegExp("^(\\d{2})[" + delim1 + "](\\d{2})[" + delim2 + "](\\d{4})$");
                         }
                         var matched = dateRegexp.exec(value);
                         if(matched != null) {
                            if (!isValidDate(matched[2], matched[1], matched[3])) {
                               if (i == 0) {
                                   focusField = form[oDate[x][0]];
                               }
                               fields[i++] = oDate[x][1];
                               bValid =  false;
                            }
                         } else {
                            if (i == 0) {
                                focusField = form[oDate[x][0]];
                            }
                            fields[i++] = oDate[x][1];
                            bValid =  false;
                         }
                     } else if ((orderMonth < orderYear && orderMonth > orderDay)) {
                         var iDelim1 = orderDay + DAY.length;
                         var iDelim2 = orderMonth + MONTH.length;
                         var delim1 = datePattern.substring(iDelim1, iDelim1 + 1);
                         var delim2 = datePattern.substring(iDelim2, iDelim2 + 1);
                         if (iDelim1 == orderMonth && iDelim2 == orderYear) {
                             dateRegexp = new RegExp("^(\\d{2})(\\d{2})(\\d{4})$");
                         } else if (iDelim1 == orderMonth) {
                             dateRegexp = new RegExp("^(\\d{2})(\\d{2})[" + delim2 + "](\\d{4})$");
                         } else if (iDelim2 == orderYear) {
                             dateRegexp = new RegExp("^(\\d{2})[" + delim1 + "](\\d{2})(\\d{4})$");
                         } else {
                             dateRegexp = new RegExp("^(\\d{2})[" + delim1 + "](\\d{2})[" + delim2 + "](\\d{4})$");
                         }
                         var matched = dateRegexp.exec(value);
                         if(matched != null) {
                             if (!isValidDate(matched[1], matched[2], matched[3])) {
                                 if (i == 0) {
                                     focusField = form[oDate[x][0]];
                                 }
                                 fields[i++] = oDate[x][1];
                                 bValid =  false;
                              }
                         } else {
                             if (i == 0) {
                                 focusField = form[oDate[x][0]];
                             }
                             fields[i++] = oDate[x][1];
                             bValid =  false;
                         }
                     } else if ((orderMonth > orderYear && orderMonth < orderDay)) {
                         var iDelim1 = orderYear + YEAR.length;
                         var iDelim2 = orderMonth + MONTH.length;
                         var delim1 = datePattern.substring(iDelim1, iDelim1 + 1);
                         var delim2 = datePattern.substring(iDelim2, iDelim2 + 1);
                         if (iDelim1 == orderMonth && iDelim2 == orderDay) {
                             dateRegexp = new RegExp("^(\\d{4})(\\d{2})(\\d{2})$");
                         } else if (iDelim1 == orderMonth) {
                             dateRegexp = new RegExp("^(\\d{4})(\\d{2})[" + delim2 + "](\\d{2})$");
                         } else if (iDelim2 == orderDay) {
                             dateRegexp = new RegExp("^(\\d{4})[" + delim1 + "](\\d{2})(\\d{2})$");
                         } else {
                             dateRegexp = new RegExp("^(\\d{4})[" + delim1 + "](\\d{2})[" + delim2 + "](\\d{2})$");
                         }
                         var matched = dateRegexp.exec(value);
                         if(matched != null) {
                             if (!isValidDate(matched[3], matched[2], matched[1])) {
                                 if (i == 0) {
                                     focusField = form[oDate[x][0]];
                                  }
                                  fields[i++] = oDate[x][1];
                                  bValid =  false;
                              }
                          } else {
                              if (i == 0) {
                                  focusField = form[oDate[x][0]];
                              }
                              fields[i++] = oDate[x][1];
                              bValid =  false;
                          }
                     } else {
                         if (i == 0) {
                             focusField = form[oDate[x][0]];
                         }
                         fields[i++] = oDate[x][1];
                         bValid =  false;
                     }
                  }
               }
               if (fields.length > 0) {
                  focusField.focus();
                  alert(fields.join('\n'));
               }
               return bValid;
            }

        function isValidDate(day, month, year) {
            if (month < 1 || month > 12) {
                    return false;
                }
                if (day < 1 || day > 31) {
                    return false;
                }
                if ((month == 4 || month == 6 || month == 9 || month == 11) &&
                    (day == 31)) {
                    return false;
                }
                if (month == 2) {
                    var leap = (year % 4 == 0 &&
                               (year % 100 != 0 || year % 400 == 0));
                    if (day>29 || (day == 29 && !leap)) {
                        return false;
                    }
                }
                return true;
            } ]]>   </ javascript > 
         </ validator > 
         <!--  range is deprecated use intRange instead  --> 
         < validator  name ="range"  
            classname ="org.apache.struts.validator.FieldChecks"  
            method ="validateIntRange"  
            methodParams ="java.lang.Object,
                       org.apache.commons.validator.ValidatorAction,
                       org.apache.commons.validator.Field,
                       org.apache.struts.action.ActionErrors,
                       javax.servlet.http.HttpServletRequest"  
            depends ="integer"  msg ="errors.range" > 
             < javascript > <![CDATA[ 
            function validateRange(form) {
                return validateIntRange(form);
            } ]]>   </ javascript > 
         </ validator > 
         < validator  name ="intRange"  
            classname ="org.apache.struts.validator.FieldChecks"  
            method ="validateIntRange"  
            methodParams ="java.lang.Object,
                       org.apache.commons.validator.ValidatorAction,
                       org.apache.commons.validator.Field,
                       org.apache.struts.action.ActionErrors,
                       javax.servlet.http.HttpServletRequest"  
            depends ="integer"  msg ="errors.range" > 
             < javascript > <![CDATA[ 
            function validateIntRange(form) {
                var isValid = true;
                var focusField = null;
                var i = 0;
                var fields = new Array();
                oRange = new intRange();
                for (x in oRange) {
                    var field = form[oRange[x][0]];
                    
                    if ((field.type == 'text' ||
                         field.type == 'textarea') &&
                        (field.value.length > 0)) {
                        
                        var iMin = parseInt(oRange[x][2]("min"));
                        var iMax = parseInt(oRange[x][2]("max"));
                        var iValue = parseInt(field.value);
                        if (!(iValue >= iMin && iValue <= iMax)) {
                            if (i == 0) {
                                focusField = field;
                            }
                            fields[i++] = oRange[x][1];
                            isValid = false;
                        }
                    }
                }
                if (fields.length > 0) {
                    focusField.focus();
                    alert(fields.join('\n'));
                }
                return isValid;
            } ]]>   </ javascript > 
         </ validator > 
         < validator  name ="floatRange"  
            classname ="org.apache.struts.validator.FieldChecks"  
            method ="validateFloatRange"  
            methodParams ="java.lang.Object,
                       org.apache.commons.validator.ValidatorAction,
                       org.apache.commons.validator.Field,
                       org.apache.struts.action.ActionErrors,
                       javax.servlet.http.HttpServletRequest"  
            depends ="float"  msg ="errors.range" > 
             < javascript > <![CDATA[ 
            function validateFloatRange(form) {
                var isValid = true;
                var focusField = null;
                var i = 0;
                var fields = new Array();
                oRange = new floatRange();
                for (x in oRange) {
                    var field = form[oRange[x][0]];
                    
                    if ((field.type == 'text' ||
                         field.type == 'textarea') &&
                        (field.value.length > 0)) {
                        
                        var fMin = parseFloat(oRange[x][2]("min"));
                        var fMax = parseFloat(oRange[x][2]("max"));
                        var fValue = parseFloat(field.value);
                        if (!(fValue >= fMin && fValue <= fMax)) {
                            if (i == 0) {
                                focusField = field;
                            }
                            fields[i++] = oRange[x][1];
                            isValid = false;
                        }
                    }
                }
                if (fields.length > 0) {
                    focusField.focus();
                    alert(fields.join('\n'));
                }
                return isValid;
            } ]]>   </ javascript > 
         </ validator > 
         < validator  name ="creditCard"  
            classname ="org.apache.struts.validator.FieldChecks"  
            method ="validateCreditCard"  
            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.creditcard" > 
             < javascript > <![CDATA[ 
            function validateCreditCard(form) {
                var bValid = true;
                var focusField = null;
                var i = 0;
                var fields = new Array();
                oCreditCard = new creditCard();
                for (x in oCreditCard) {
                    if ((form[oCreditCard[x][0]].type == 'text' ||
                         form[oCreditCard[x][0]].type == 'textarea') &&
                        (form[oCreditCard[x][0]].value.length > 0)) {
                        if (!luhnCheck(form[oCreditCard[x][0]].value)) {
                            if (i == 0) {
                                focusField = form[oCreditCard[x][0]];
                            }
                            fields[i++] = oCreditCard[x][1];
                            bValid = false;
                        }
                    }
                }
                if (fields.length > 0) {
                    focusField.focus();
                    alert(fields.join('\n'));
                }
                return bValid;
            }

            /**
             * Reference: http://www.ling.nwu.edu/~sburke/pub/luhn_lib.pl
             */
            function luhnCheck(cardNumber) {
                if (isLuhnNum(cardNumber)) {
                    var no_digit = cardNumber.length;
                    var oddoeven = no_digit & 1;
                    var sum = 0;
                    for (var count = 0; count < no_digit; count++) {
                        var digit = parseInt(cardNumber.charAt(count));
                        if (!((count & 1) ^ oddoeven)) {
                            digit *= 2;
                            if (digit > 9) digit -= 9;
                        };
                        sum += digit;
                    };
                    if (sum == 0) return false;
                    if (sum % 10 == 0) return true;
                };
                return false;
            }

            function isLuhnNum(argvalue) {
                argvalue = argvalue.toString();
                if (argvalue.length == 0) {
                    return false;
                }
                for (var n = 0; n < argvalue.length; n++) {
                    if ((argvalue.substring(n, n+1) < "0") ||
                        (argvalue.substring(n,n+1) > "9")) {
                        return false;
                    }
                }
                return true;
            } ]]>   </ javascript > 
         </ validator > 
         < validator  name ="email"  
            classname ="org.apache.struts.validator.FieldChecks"  
            method ="validateEmail"  
            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.email" > 
             < javascript > <![CDATA[ 
            function validateEmail(form) {
                var bValid = true;
                var focusField = null;
                var i = 0;
                var fields = new Array();
                oEmail = new email();
                for (x in oEmail) {
                    if ((form[oEmail[x][0]].type == 'text' ||
                         form[oEmail[x][0]].type == 'textarea') &&
                        (form[oEmail[x][0]].value.length > 0)) {
                        if (!checkEmail(form[oEmail[x][0]].value)) {
                            if (i == 0) {
                                focusField = form[oEmail[x][0]];
                            }
                            fields[i++] = oEmail[x][1];
                            bValid = false;
                        }
                    }
                }
                if (fields.length > 0) {
                    focusField.focus();
                    alert(fields.join('\n'));
                }
                return bValid;
            }

            /**
             * Reference: Sandeep V. Tamhankar (stamhankar@hotmail.com),
             * http://javascript.internet.com
             */
            function checkEmail(emailStr) {
               if (emailStr.length == 0) {
                   return true;
               }
               var emailPat=/^(.+)@(.+)$/;
               var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]";
               var validChars="\[^\\s" + specialChars + "\]";
               var quotedUser="(\"[^\"]*\")";
               var ipDomainPat=/^(\d{1,3})[.](\d{1,3})[.](\d{1,3})[.](\d{1,3})$/;
               var atom=validChars + '+';
               var word="(" + atom + "|" + quotedUser + ")";
               var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
               var domainPat=new RegExp("^" + atom + "(\\." + atom + ")*$");
               var matchArray=emailStr.match(emailPat);
               if (matchArray == null) {
                   return false;
               }
               var user=matchArray[1];
               var domain=matchArray[2];
               if (user.match(userPat) == null) {
                   return false;
               }
               var IPArray = domain.match(ipDomainPat);
               if (IPArray != null) {
                   for (var i = 1; i <= 4; i++) {
                      if (IPArray[i] > 255) {
                         return false;
                      }
                   }
                   return true;
               }
               var domainArray=domain.match(domainPat);
               if (domainArray == null) {
                   return false;
               }
               var atomPat=new RegExp(atom,"g");
               var domArr=domain.match(atomPat);
               var len=domArr.length;
               if ((domArr[domArr.length-1].length < 2) ||
                   (domArr[domArr.length-1].length > 3)) {
                   return false;
               }
               if (len < 2) {
                   return false;
               }
               return true;
            } ]]>   </ javascript > 
         </ validator > 
         <!-- 
          ÅжÏÊý×éÿ¸öÊýÖµ¶¼²»ÄÜΪ¿Õ
          ÕÔÆ·º£  2004
           --> 
         < validator  name ="requiredArray"  
            classname ="org.apache.struts.validator.FieldChecks"  
            method ="validateRequiredArray"  
            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.required"  
            jsFunctionName ="RequiredArrayValidations" > 
             < javascript > <![CDATA[ 
            function validateRequiredArray(form) {
                var isValid = true;
                var focusField = null;
                var i = 0;
                var fields = new Array();
                var j=0;
                oRequired = new RequiredArrayValidations();
                for (x in oRequired) {
                    var field = form[oRequired[x][0]];
                    for(var ii=0;ii<field.length;ii++){
                        if(field[ii].value.length>0){
                            j++;
                        }
                    }  
                     if (j < field.length) {
                        
                            if (i == 0) {
                                focusField = field;
                            }
                            fields[i++] = oRequired[x][1];
                            isValid = false;
                    }
                }

                if (fields.length > 0) {
                   alert(fields.join('\n'));
                }
                return isValid;
            }
             ]]>   </ javascript > 
         </ validator > 
         <!-- 
          ÅжÏÊý×éÿ¸ö²»Îª¿ÕµÄÊýÖµ¶¼±ØÐëΪÕûÐÍ
          ÕÔÆ·º£  2004
           --> 
         < validator  name ="integerArray"  
            classname ="org.apache.struts.validator.FieldChecks"  
            method ="validateIntegerArray"  
            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 ="IntegerArrayValidations" > 
             < javascript > <![CDATA[ 
            function validateIntegerArray(form) {
                var bValid = true;
                var focusField = null;
                var i = 0;
                var j=0;
                var fields = new Array();
                oInteger = new IntegerArrayValidations();
                for (x in oInteger) {
                    var field = form[oInteger[x][0]];
                    for(var ii=0;ii<field.length;ii++){
                        var value=field[ii].value;
                        if (value.length > 0) {
                        
                            if (!isAllDigits(value)) {
                                bValid = false;                                
                                j++;
                                if(j==1){
                                    focusField = field[ii];
                                }
                                
                            } else {
                                var iValue = parseInt(value);
                                if (isNaN(iValue) || !(iValue >= -2147483648 && iValue <= 2147483647)) {
                                    bValid = false;
                                    j++;
                                    if(j==1){
                                        focusField = field[ii];
                                    }
                               }
                           }
                       }
                    }  
                     if (j > 0) {
                        
                            fields[i++] = oInteger[x][1];
                            isValid = false;
                    }
                }
                    
                if (fields.length > 0) {
                   focusField.focus();
                   alert(fields.join('\n'));
                }
                return bValid;
            }

             ]]>   </ javascript > 
         </ validator > 
         <!-- 
          ÅжÏÊý×éÿ¸ö²»Îª¿ÕµÄÊýÖµ¶¼±ØÐëΪ¸¡µãÐÍ
          ÕÔÆ·º£  2004
           --> 
         < validator  name ="floatArray"  
            classname ="org.apache.struts.validator.FieldChecks"  
            method ="validateFloatArray"  
            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.float"  
            jsFunctionName ="FloatArrayValidations" > 
             < javascript > <![CDATA[ 
            function validateFloatArray(form) {
                var bValid = true;
                var focusField = null;
                var i = 0;
                var j=0;
                var fields = new Array();
                oFloat = new FloatArrayValidations();
                for (x in oFloat) {
                    var field = form[oFloat[x][0]];
                    for(var ii=0;ii<field.length;ii++){
                        var value=field[ii].value;
                        
                       if (value.length > 0) {
                            // remove '.' before checking digits
                            var tempArray = value.split('.');
                            var joinedString= tempArray.join('');

                            if (!isAllDigits(joinedString)) {
                                bValid = false;
                                j++;
                                if (j == 1) {
                                    focusField = field[ii];
                                }
                                
                            } else {
                                var iValue = parseFloat(value);
                                if (isNaN(iValue)) {
                                    j++;
                                    if (j == 1) {
                                        focusField = field[ii];
                                    }
                                    bValid = false;
                                }
                            }
                        }
                    }  
                     if (j > 0) {
                        
                            fields[i++] = oFloat[x][1];
                            isValid = false;
                    }
                }
                    
                if (fields.length > 0) {
                   focusField.focus();
                   alert(fields.join('\n'));
                }
                return bValid;
            }

             ]]>   </ javascript > 
         </ validator > 
         <!-- 
          ÅжÏÊý×éÿ¸ö²»Îª¿ÕµÄÊýÖµ¶¼±ØÐëΪ˫¾«¶ÈÐÍ
          ÕÔÆ·º£  2004
           -->         
         < validator  name ="doubleArray"  
            classname ="org.apache.struts.validator.FieldChecks"  
            method ="validateDoubleArray"  
            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.double" /> 
         <!-- 
          ÅжÏÊý×éÿ¸ö²»Îª¿ÕµÄÊýÖµ¶¼±ØÐëΪÈÕÆÚÐÍ
          ÕÔÆ·º£  2004
           -->             
         < validator  name ="dateArray"  
            classname ="org.apache.struts.validator.FieldChecks"  
            method ="validateDateArray"  
            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.date"  jsFunctionName ="DateArrayValidations" > 
             < javascript > <![CDATA[ 
            function validateDateArray(form) {
                var bValid = true;
                var focusField = null;
                var i = 0;
                var j=0;
                var fields = new Array();
                oDate = new DateArrayValidations();
                for (x in oDate) {
                    var field = form[oDate[x][0]];
                    for(var ii=0;ii<field.length;ii++){
                        var value=field[ii].value;
                        var datePattern = oDate[x][2]("datePatternStrict");
                        if ((value.length > 0) &&
                           (datePattern.length > 0)) {
                          var MONTH = "MM";
                          var DAY = "dd";
                          var YEAR = "yyyy";
                          var orderMonth = datePattern.indexOf(MONTH);
                          var orderDay = datePattern.indexOf(DAY);
                          var orderYear = datePattern.indexOf(YEAR);
                          if ((orderDay < orderYear && orderDay > orderMonth)) {
                             var iDelim1 = orderMonth + MONTH.length;
                             var iDelim2 = orderDay + DAY.length;
                             var delim1 = datePattern.substring(iDelim1, iDelim1 + 1);
                             var delim2 = datePattern.substring(iDelim2, iDelim2 + 1);
                             if (iDelim1 == orderDay && iDelim2 == orderYear) {
                                dateRegexp = new RegExp("^(\\d{2})(\\d{2})(\\d{4})$");
                             } else if (iDelim1 == orderDay) {
                                dateRegexp = new RegExp("^(\\d{2})(\\d{2})[" + delim2 + "](\\d{4})$");
                             } else if (iDelim2 == orderYear) {
                                dateRegexp = new RegExp("^(\\d{2})[" + delim1 + "](\\d{2})(\\d{4})$");
                             } else {
                                dateRegexp = new RegExp("^(\\d{2})[" + delim1 + "](\\d{2})[" + delim2 + "](\\d{4})$");
                             }
                             var matched = dateRegexp.exec(value);
                             if(matched != null) {
                                if (!isValidDate(matched[2], matched[1], matched[3])) {
                                   
                                   bValid =  false;
                                   j++;
                                }
                             } else {
                                bValid =  false;
                                j++;
                             }
                           } else if ((orderMonth < orderYear && orderMonth > orderDay)) {
                             var iDelim1 = orderDay + DAY.length;
                             var iDelim2 = orderMonth + MONTH.length;
                             var delim1 = datePattern.substring(iDelim1, iDelim1 + 1);
                             var delim2 = datePattern.substring(iDelim2, iDelim2 + 1);
                             if (iDelim1 == orderMonth && iDelim2 == orderYear) {
                                 dateRegexp = new RegExp("^(\\d{2})(\\d{2})(\\d{4})$");
                             } else if (iDelim1 == orderMonth) {
                                 dateRegexp = new RegExp("^(\\d{2})(\\d{2})[" + delim2 + "](\\d{4})$");
                             } else if (iDelim2 == orderYear) {
                                 dateRegexp = new RegExp("^(\\d{2})[" + delim1 + "](\\d{2})(\\d{4})$");
                             } else {
                                 dateRegexp = new RegExp("^(\\d{2})[" + delim1 + "](\\d{2})[" + delim2 + "](\\d{4})$");
                             }
                             var matched = dateRegexp.exec(value);
                             if(matched != null) {
                                 if (!isValidDate(matched[1], matched[2], matched[3])) {
                                     j++;
                                     bValid =  false;
                                  }
                             } else {
                                 j++;
                                 bValid =  false;
                             }
                           } else if ((orderMonth > orderYear && orderMonth < orderDay)) {
                             var iDelim1 = orderYear + YEAR.length;
                             var iDelim2 = orderMonth + MONTH.length;
                             var delim1 = datePattern.substring(iDelim1, iDelim1 + 1);
                             var delim2 = datePattern.substring(iDelim2, iDelim2 + 1);
                             if (iDelim1 == orderMonth && iDelim2 == orderDay) {
                                 dateRegexp = new RegExp("^(\\d{4})(\\d{2})(\\d{2})$");
                             } else if (iDelim1 == orderMonth) {
                                 dateRegexp = new RegExp("^(\\d{4})(\\d{2})[" + delim2 + "](\\d{2})$");
                             } else if (iDelim2 == orderDay) {
                                 dateRegexp = new RegExp("^(\\d{4})[" + delim1 + "](\\d{2})(\\d{2})$");
                             } else {
                                 dateRegexp = new RegExp("^(\\d{4})[" + delim1 + "](\\d{2})[" + delim2 + "](\\d{2})$");
                             }
                             var matched = dateRegexp.exec(value);
                             if(matched != null) {
                                 if (!isValidDate(matched[3], matched[2], matched[1])) {
                                     j++;
                                     bValid =  false;
                                  }
                              } else {
                                  j++;
                                  bValid =  false;
                              }
                         } else {
                             j++;
                             bValid =  false;
                         }
                      }                      
                      }
                     if (j > 0) {
                        
                            fields[i++] = oDate[x][1];
                            isValid = false;
                     }
                }
                    
                if (fields.length > 0) {
                   alert(fields.join('\n'));
                }
                return bValid;
            }

             ]]>   </ javascript > 
         </ validator > 
     </ global > 
 
 </ form-validation >

 

© 著作权归作者所有

共有 人打赏支持
ruyees
粉丝 3
博文 71
码字总数 0
作品 0
深圳
产品经理
JAVA SSH 框架介绍

SSH 为 struts+spring+hibernate 的一个集成框架,是目前较流行的一种JAVA Web应用程序开源框架。  Struts   Struts是一个基于Sun J2EE平台的MVC框架,主要是采用Servlet和JSP技术来实现的...

小梅菜鸟 ⋅ 2012/04/20 ⋅ 0

excel数据导入导出

各位中午好! 我现在做一个旅游管理系统,遇到一些问题。 如何实现页面点击按钮将EXCEL数据导入到数据中,另外,也能实现点击按钮实现将数据库表导出到EXCEL中。 我用的开发语言是JAVA,数据...

汪斌 ⋅ 2011/03/31 ⋅ 4

基于Struts+Spring+Hibernate的使用和部署

就现在WEB开发而言,J2EE企业级开发技术比较成熟,开发模式模式也比较繁多,较流行开发模式MVC更是普遍,而基于MVC模式开发的框架也是种类繁多,现在使用最多的可能就是SSH这三种框架,所以展...

chenruibing ⋅ 2015/08/18 ⋅ 0

struts+spring+hibernate分别用到了什么设计模式

struts+spring+hibernate分别用到了什么设计模式,请大家知无不答,共同讨论。 并举例说明哪个框架的哪个地方用到了哪个java设计模式.

skyone ⋅ 2012/12/27 ⋅ 14

登陆界面不输密码点一次登陆出现一个用户名和密码不能为空(点n个出现n个)

环境ssh(struts+spring+hibernate) 编写好登陆界面什么都正常,就是点击登陆时无限的出现用户名和密码不能为空 错误原因:没有在action中配置多例,action默认是单例的 scope=“prototype...

lzw_me ⋅ 2014/05/29 ⋅ 0

想学习Struts+Spring+Hibernate给推荐本这样的书吧

想学习Struts+Spring+Hibernate 的整合开发 大家给推荐本这样的书吧 最好是新版的 谢谢了

帅气的鱼 ⋅ 2010/12/16 ⋅ 20

java-学习路线

学习路线 java基础 java基础 java界面编程 java API java语法 AWT java IO 面向对象 事件机制 多线程 常见api Swing 网络编程 集合框架 反射注解 数据库开发 SQL基础 JDBC编程 JDBC高级 SQL基...

zhaoliang1131 ⋅ 2017/01/17 ⋅ 0

异常org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name java.lang.Long

使用了struts+spring+hibernate 在注入的是的时候发生org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name java.lang.Long。大侠帮忙看看......

深蓝的天空 ⋅ 2014/02/11 ⋅ 0

ssh三大框架对于新手先学哪个比较好点

学java的,但没有接触过ssh( struts+spring+hibernate),想问一句,先学哪个比较好点?推荐一些好点的书籍或视频也行,

奋斗的少年 ⋅ 2015/04/08 ⋅ 20

flash上传头像剪裁预览组件 2.1 版本发布了

flash上传头像剪裁预览组件 2.1 发布了,此版本现已提供下载: 下载地址 : http://www.hdfu.net/down.html 更新内容如下: 解决 flash 13 以上版本,点击 "本地上传图片" 失败bug 新增加 ss...

easymvc ⋅ 2014/12/01 ⋅ 68

没有更多内容

加载失败,请刷新页面

加载更多

下一页

sbt网络问题解决方案

http://dblab.xmu.edu.cn/blog/maven-network-problem/

狐狸老侠 ⋅ 3分钟前 ⋅ 0

大数据,必须掌握的10项顶级安全技术

我们看到越来越多的数据泄漏事故、勒索软件和其他类型的网络攻击,这使得安全成为一个热门话题。 去年,企业IT面临的威胁仍然处于非常高的水平,每天都会看到媒体报道大量数据泄漏事故和攻击...

p柯西 ⋅ 47分钟前 ⋅ 0

Linux下安装配置Hadoop2.7.6

前提 安装jdk 下载 wget http://mirrors.hust.edu.cn/apache/hadoop/common/hadoop-2.7.6/hadoop-2.7.6.tar.gz 解压 配置 vim /etc/profile # 配置java环境变量 export JAVA_HOME=/opt/jdk1......

晨猫 ⋅ 52分钟前 ⋅ 0

crontab工具介绍

crontab crontab 是一个用于设置周期性被执行的任务工具。 周期性执行的任务列表称为Cron Table crontab(选项)(参数) -e:编辑该用户的计时器设置; -l:列出该用户的计时器设置; -r:删除该...

Linux学习笔记 ⋅ 今天 ⋅ 0

深入Java多线程——Java内存模型深入(2)

5. final域的内存语义 5.1 final域的重排序规则 1.对于final域,编译器和处理器要遵守两个重排序规则: (1)在构造函数内对一个final域的写入,与随后把这个被构造对象的引用赋值给一个引用...

江左煤郎 ⋅ 今天 ⋅ 0

面试-正向代理和反向代理

面试-正向代理和反向代理 Nginx 是一个高性能的反向代理服务器,但同时也支持正向代理方式的配置。

秋日芒草 ⋅ 今天 ⋅ 0

Spring 依赖注入(DI)

1、Setter方法注入: 通过设置方法注入依赖。这种方法既简单又常用。 类中定义set()方法: public class HelloWorldOutput{ HelloWorld helloWorld; public void setHelloWorld...

霍淇滨 ⋅ 昨天 ⋅ 0

马氏距离与欧氏距离

马氏距离 马氏距离也可以定义为两个服从同一分布并且其协方差矩阵为Σ的随机变量之间的差异程度。 如果协方差矩阵为单位矩阵,那么马氏距离就简化为欧氏距离,如果协方差矩阵为对角阵,则其也...

漫步当下 ⋅ 昨天 ⋅ 0

聊聊spring cloud的RequestRateLimiterGatewayFilter

序 本文主要研究一下spring cloud的RequestRateLimiterGatewayFilter GatewayAutoConfiguration @Configuration@ConditionalOnProperty(name = "spring.cloud.gateway.enabled", matchIfMi......

go4it ⋅ 昨天 ⋅ 0

Spring clound 组件

Spring Cloud技术应用从场景上可以分为两大类:润物无声类和独挑大梁类。 润物无声,融合在每个微服务中、依赖其它组件并为其提供服务。 Ribbon,客户端负载均衡,特性有区域亲和、重试机制。...

英雄有梦没死就别停 ⋅ 昨天 ⋅ 0

没有更多内容

加载失败,请刷新页面

加载更多

下一页

返回顶部
顶部