本文整理汇总了Java中org.springframework.util.AntPathMatcher.match方法的典型用法代码示例。如果您正苦于以下问题:Java AntPathMatcher.match方法的具体用法?Java AntPathMatcher.match怎么用?Java AntPathMatcher.match使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.util.AntPathMatcher
的用法示例。
在下文中一共展示了AntPathMatcher.match方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: matchesPathPattern
import org.springframework.util.AntPathMatcher; //导入方法依赖的package包/类
public static boolean matchesPathPattern(String pattern) {
String path = (String)RequestContextHolder.getRequestAttributes().getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE, RequestAttributes.SCOPE_REQUEST);
// If They are both blank, then there is a default pattern
if (StringUtils.isEmpty(path) && StringUtils.isEmpty(pattern)) {
return true;
}
AntPathMatcher apm = new AntPathMatcher();
return apm.match(pattern, path);
}
示例2: testAntMatcher
import org.springframework.util.AntPathMatcher; //导入方法依赖的package包/类
@Test
public void testAntMatcher(){
AntPathMatcher path = new AntPathMatcher();
boolean rs = path.match("/user.*", "/user.json?aaa=bbb&cc=ddd");
Assert.assertTrue(rs);
//后缀的点号变成可选的写法?
rs = path.match("/user.*", "/user");
Assert.assertFalse(rs);
}
示例3: getRoutingInfo
import org.springframework.util.AntPathMatcher; //导入方法依赖的package包/类
/**
* getRoutingInfo: Returns the routing info for the given request and method.
* @param requestUri
* @param httpMethod
* @return RoutingInfo The routing info for the matching route or <code>null</code>
* if no match was found.
*/
public RoutingInfo getRoutingInfo(String requestUri, String httpMethod) {
// create a new path matcher instance.
AntPathMatcher matcher = new AntPathMatcher();
// define a map to hold parameter versions.
Map<String, String> pathParams = null;
// for each defined route
for (IRoute route : _routes) {
// extract the URI.
String routeUri = route.getUri();
// if the defined route uses the given http method and the URIs match
if (httpMethod.equals(route.getHttpMethod()) && matcher.match(routeUri, requestUri)) {
// extract the template parameters from the uri.
pathParams = matcher.extractUriTemplateVariables(routeUri, requestUri);
// define a new routing info object
RoutingInfo routingInfo = new RoutingInfo();
// set the values
routingInfo.setRoute(route);
routingInfo.setPathParameters(pathParams);
// return the instance
return routingInfo;
}
}
// if we get here, no match.
return null;
}
示例4: matchLatestByPattern
import org.springframework.util.AntPathMatcher; //导入方法依赖的package包/类
private VersionEntry matchLatestByPattern(List<VersionEntry> results, String version) {
AntPathMatcher matcher = new AntPathMatcher();
for (VersionEntry result : results) {
if (matcher.match(version, result.getVersion())) {
return result;
}
}
return null;
}
示例5: matchByPattern
import org.springframework.util.AntPathMatcher; //导入方法依赖的package包/类
private void matchByPattern(ArtifactVersionsResult artifactVersions, String version) {
List<VersionEntry> filteredResults = Lists.newArrayList();
AntPathMatcher matcher = new AntPathMatcher();
for (VersionEntry result : artifactVersions.getResults()) {
if (matcher.match(version, result.getVersion())) {
filteredResults.add(result);
}
}
artifactVersions.setResults(filteredResults);
}
示例6: getInterceptors
import org.springframework.util.AntPathMatcher; //导入方法依赖的package包/类
public List<Interceptor> getInterceptors(String path, AntPathMatcher matcher) {
List<Interceptor> interceptors = new ArrayList<Interceptor>();
for (InterceptorConfigHolder.InterceptorConfig interceptorConfig : interceptorConfigs) {
if (matcher.match(interceptorConfig.getPath(), path)) {
interceptors.add(SpringContainer.getBean(interceptorConfig.getClazz()));
}
}
return interceptors;
}
示例7: listFilesAndDirsFromDirectory
import org.springframework.util.AntPathMatcher; //导入方法依赖的package包/类
protected List<FileInfo> listFilesAndDirsFromDirectory(String pattern, String fileSpecification,
IDirectory resourceDirectory, AntPathMatcher pathMatcher) {
List<FileInfo> files = new ArrayList<FileInfo>();
List<FileInfo> matchedFiles = new ArrayList<FileInfo>();
files = resourceDirectory.listFiles(pattern);
for (FileInfo file : files) {
if (pathMatcher.match(fileSpecification, file.getName())) {
matchedFiles.add(file);
}
}
return matchedFiles;
}
示例8: isBranchNotExcluded
import org.springframework.util.AntPathMatcher; //导入方法依赖的package包/类
private boolean isBranchNotExcluded(String branchName) {
AntPathMatcher matcher = new AntPathMatcher();
for (String excludePattern : excludedBranches) {
if (matcher.match(excludePattern, branchName)) {
return false;
}
}
return true;
}
示例9: isBranchIncluded
import org.springframework.util.AntPathMatcher; //导入方法依赖的package包/类
private boolean isBranchIncluded(String branchName) {
AntPathMatcher matcher = new AntPathMatcher();
for (String includePattern : includedBranches) {
if (matcher.match(includePattern, branchName)) {
return true;
}
}
return includedBranches.isEmpty();
}
示例10: antTest
import org.springframework.util.AntPathMatcher; //导入方法依赖的package包/类
@Test
public void antTest() {
AntPathMatcher antPathMatcher = new AntPathMatcher();
String pattern = "/webjars/{webjar}/**/{partialPath:.+}";
String path = "/webjars/boostrap/js/boostrap.js";
boolean result = antPathMatcher.match(pattern, path);
Assert.assertTrue(result);
}
示例11: testAntMatcher
import org.springframework.util.AntPathMatcher; //导入方法依赖的package包/类
@Test
public void testAntMatcher(){
AntPathMatcher req = new AntPathMatcher();
boolean res = req.match("/user.*", "/user.json");
Assert.assertTrue(res);
res = req.match("/**/api/**", "/service/api/user");
res = req.match("/**/api/**", "/api/user");
res = req.match("/**/api/**", "/api/user/1");
res = req.match("/**/api/**", "/api/user/1?aa=bb&cc=dd");
Assert.assertTrue(res);
res = req.match("*zh.*", "user_zh.html");
Assert.assertTrue(res);
res = req.match("*zh.*", "/user_zh.html");
Assert.assertFalse(res);
res = req.match("**zh.*", "user_zh.html");
Assert.assertTrue(res);
res = req.match("**zh.*", "/user_zh.html");
Assert.assertFalse(res);
res = req.match("**/*zh.*", "/user_zh.html");
Assert.assertFalse(res);
res = req.match("/*zh.*", "/user_zh.html");
Assert.assertTrue(res);
res = req.match("/user*", "/user");
Assert.assertTrue(res);
res = req.match("/user*", "/user.json");
Assert.assertTrue(res);
res = req.match("/user*", "/userInfo");
Assert.assertTrue(res);
res = req.match("/user*", "/user/1");
Assert.assertFalse(res);
res = req.match("/user**", "/user");
Assert.assertTrue(res);
res = req.match("/user**", "/user.json");
Assert.assertTrue(res);
res = req.match("/user**", "/userInfo");
Assert.assertTrue(res);
res = req.match("/user*/**", "/userInfo");
Assert.assertTrue(res);
res = req.match("/user*/**", "/user/1.json");
Assert.assertTrue(res);
res = req.match("/user/*", "/user/1");
Assert.assertTrue(res);
res = req.match("/user/*", "/user/1.json");
Assert.assertTrue(res);
res = req.match("/user/*", "/user/aaa/1.json");
Assert.assertFalse(res);
res = req.match("/user/**", "/user/1.json");
Assert.assertTrue(res);
res = req.match("/user/**", "/user/aaa/1.json");
Assert.assertTrue(res);
res = req.match("/service/swagger**", "/service/swagger-resources");
Assert.assertTrue(res);
res = req.match("/service/swagger**/**", "/service/swagger-resources/configuration");
Assert.assertTrue(res);
res = req.match("/service/swagger**/**", "/service/swagger-resources");
Assert.assertTrue(res);
res = req.match("/service/swagger**", "/service/swagger-resources/configuration/ui");
Assert.assertFalse(res);
res = req.match("/service/webjars/**/**", "/service/webjars/springfox-swagger-ui/css/typography.css");
Assert.assertTrue(res);
}