com.kukababy.utils.UrlUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dbquery Show documentation
Show all versions of dbquery Show documentation
Unified query of Mongodb and Sql database.
The newest version!
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.kukababy.utils;
import java.util.regex.Pattern;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* @describe 描述
* @author [email protected]
* @date 2014-3-26
*/
public class UrlUtil {
private static final Logger log = LoggerFactory.getLogger(UrlUtil.class);
public static void main(String args[]) {
Pattern exclusions = exclusionsReg("/,/login,/login.html,*.js,*.gif,*.jpg,*.png,*.css,*.ico,*.bmp,/images/*");
System.out.println(exclusions.matcher("/images/a.html").matches());
}
public static Pattern exclusionsReg(String _exclusions) {
String dars[] = _exclusions.split(",");
StringBuilder sb = new StringBuilder();
for (String key : dars) {
if (sb.length() > 0) {
sb.append("||");
}
key = key.replaceAll("\\.", "\\\\.");
key = key.replaceAll("\\*", ".*");
sb.append("(").append(key).append(")");
}
log.info(sb.toString());
return Pattern.compile(sb.toString());
}
}