本文整理匯總了Java中org.apache.commons.validator.routines.UrlValidator.NO_FRAGMENTS屬性的典型用法代碼示例。如果您正苦於以下問題:Java UrlValidator.NO_FRAGMENTS屬性的具體用法?Java UrlValidator.NO_FRAGMENTS怎麽用?Java UrlValidator.NO_FRAGMENTS使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類org.apache.commons.validator.routines.UrlValidator
的用法示例。
在下文中一共展示了UrlValidator.NO_FRAGMENTS屬性的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: isUrlValid
/**
* @param url
* @return
*/
public static boolean isUrlValid(String url) {
String[] schemes = { "http", "https" };
UrlValidator valid = new UrlValidator(schemes,
UrlValidator.NO_FRAGMENTS);
return valid.isValid(url);
}
示例2: isValid
@Override
public boolean isValid(final String url, String attribute) {
String[] schemes = ruleAnnotation.schemes();
long options = ruleAnnotation.allowFragments()
? 0 : UrlValidator.NO_FRAGMENTS;
UrlValidator urlValidator = schemes != null && schemes.length > 0
? new UrlValidator(schemes, options) : UrlValidator.getInstance();
return urlValidator.isValid(url);
}
示例3: validateUri
protected void validateUri(String uri) {
if (uri.length() > 200) {
throw new IllegalArgumentException("Uri is too long");
}
String[] schemes = {"http", "https"};
UrlValidator urlValidator = new UrlValidator(schemes, UrlValidator.NO_FRAGMENTS);
if (!urlValidator.isValid(uri)) {
throw new IllegalArgumentException("Uri (" + uri + ") is not valid");
}
}