本文整理汇总了Java中org.springframework.util.AntPathMatcher.extractPathWithinPattern方法的典型用法代码示例。如果您正苦于以下问题:Java AntPathMatcher.extractPathWithinPattern方法的具体用法?Java AntPathMatcher.extractPathWithinPattern怎么用?Java AntPathMatcher.extractPathWithinPattern使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.util.AntPathMatcher
的用法示例。
在下文中一共展示了AntPathMatcher.extractPathWithinPattern方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getFile
import org.springframework.util.AntPathMatcher; //导入方法依赖的package包/类
@RequestMapping(value = "/{solution}/**", method = {RequestMethod.GET, RequestMethod.HEAD})
@ResponseBody
public ResponseEntity<FileSystemResource> getFile(@PathVariable("solution") String solution,
HttpServletRequest request) {
String path = (String) request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);
String bestMatchPattern = (String ) request.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE);
AntPathMatcher apm = new AntPathMatcher();
path = apm.extractPathWithinPattern(bestMatchPattern, path);
File file = fileService.getFile(solution, path);
if (file.exists() && file.isFile()) {
try {
String detect = tika.detect(file);
MediaType mediaType = MediaType.parseMediaType(detect);
return ResponseEntity.ok()
.contentLength(file.length())
.contentType(mediaType)
.lastModified(file.lastModified())
.body(new FileSystemResource(file));
} catch (IOException e) {
e.printStackTrace();
}
} else {
throw new ResourceNotFoundException();
}
return null;
}
示例2: extractMatched
import org.springframework.util.AntPathMatcher; //导入方法依赖的package包/类
public static String extractMatched(final HttpServletRequest request){
String path = (String) request.getAttribute(
HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);
String bestMatchPattern = (String ) request.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE);
AntPathMatcher apm = new AntPathMatcher();
return apm.extractPathWithinPattern(bestMatchPattern, path);
}
示例3: extractPathFromPattern
import org.springframework.util.AntPathMatcher; //导入方法依赖的package包/类
/**
* Extract path from a controller mapping. /controllerUrl/** => return matched **
* @param request incoming request.
* @return extracted path
*/
public static String extractPathFromPattern(final HttpServletRequest request){
String path = (String) request.getAttribute(
HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);
String bestMatchPattern = (String ) request.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE);
AntPathMatcher apm = new AntPathMatcher();
String finalPath = apm.extractPathWithinPattern(bestMatchPattern, path);
return finalPath;
}
示例4: extractPathFromPattern
import org.springframework.util.AntPathMatcher; //导入方法依赖的package包/类
public static String extractPathFromPattern(final HttpServletRequest request) {
String path = (String) request.getAttribute(HandlerMapping.PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE);
String bestMatchPattern = (String) request.getAttribute(HandlerMapping.BEST_MATCHING_PATTERN_ATTRIBUTE);
AntPathMatcher apm = new AntPathMatcher();
String finalPath = apm.extractPathWithinPattern(bestMatchPattern, path);
return finalPath;
}