- 浏览: 939495 次
- 性别:
- 来自: 江西上饶
文章分类
- 全部博客 (460)
- p.spring (56)
- p.maven (20)
- p.ant (17)
- p.jee (18)
- p.jse (33)
- p.ofbiz (31)
- p.软件工程 (8)
- p.struts2 (5)
- p.hibernate (5)
- linux (25)
- 设计模式 (2)
- p.javascript (11)
- 硬件 (1)
- p.jsp (2)
- p.windows批处理 (1)
- 操作系统问题 (5)
- 算法 (1)
- p.mysql (7)
- p.sql (5)
- p.c (1)
- google产品 (0)
- 内存 (1)
- p.struts (1)
- p.freemarker (7)
- p.css (4)
- p.log4j (10)
- p.html (3)
- 淘宝产品 (0)
- 其他 (3)
- 编译器 (0)
- svn (4)
- p.spring.security (11)
- 图形 (0)
- p.xml (1)
- p.ssh (0)
- p.jquery (4)
- p.jdbc (3)
- p.flex (0)
- p.c++ (0)
- p.c#Net (0)
- p.assembly (0)
- p.sqlserver (0)
- p.其他 (3)
- p.webwork (21)
- p.wap (12)
- p.cglib (1)
- p.jee服务器 (11)
- windows (2)
- p.iphone (1)
- p.java.分布式与集群 (2)
- p.ibatis (16)
- p.eclipse (5)
- 架构 (2)
- http协议 (5)
- 我的个人标准 (2)
- 多线程 (1)
- 奇怪问题 (5)
- p.jira (13)
- p.httpclient (1)
- 服务器.apache (11)
- 安全防范 (1)
- p.PODAM (1)
- p.junit (16)
- fop (2)
- 硬盘安装 (1)
- powerdesigner (0)
- 单元测试 (1)
- apache commons (4)
- tomcat+apache集群 (10)
- 各类诡辩 (1)
- 安卓 (8)
- qvod (1)
- java编程基础知识考试考点及答案 (0)
- 工作总结 (4)
- oracle (0)
- spring的util工具 (3)
- json (2)
- maven (3)
- jms (19)
- p.bat (3)
- hadoop (2)
- git (3)
- nginx (1)
- p.移动开发 (1)
- shiro (3)
- 游戏破解 (1)
- react-native (7)
- ios开发 (1)
- webmagic (6)
- socks5 (1)
最新评论
-
weituotian:
说的不好,没人看的
公司系统中的菜单功能和权限功能 -
石不易:
非常详细的注解~
绑定端口和IP,Listen 与VirtualHost指令 -
spring_springmvc:
spring mvc demo教程源代码下载,地址:http: ...
spring mvc -
liyixing1:
PandaDONG 写道谢谢你啊,我已经下下来了,只是还有很多 ...
jira war安装 -
liyixing1:
PandaDONG 写道谢谢你啊,我已经下下来了,只是还有很多 ...
jira war安装
spring和ant path实现相关的主要类有两个
org.springframework.util.PathMatcher
org.springframework.util.AntPathMatcher.AntPatternComparator.AntPatternComparator
可以看下springmvc的通过url查找action的方法
Object org.springframework.web.servlet.handler.AbstractUrlHandlerMapping.getHandlerInternal(HttpServletRequest request) throws Exception
,这个方法的前面两行代码:
String lookupPath = this.urlPathHelper.getLookupPathForRequest(request);
Object handler = lookupHandler(lookupPath, request);
再看lookupHandler
Object org.springframework.web.servlet.handler.AbstractUrlHandlerMapping.lookupHandler(String urlPath, HttpServletRequest request) throws Exception
// 这里是绝对匹配,如我们的RequestMapping("/getView"),那么请求/test/getView,这种资源是可以绝对匹配上的,那么直接get就可以了。
Object handler = this.handlerMap.get(urlPath);
if (handler != null) {
// Bean name or resolved handler?
if (handler instanceof String) {
String handlerName = (String) handler;
handler = getApplicationContext().getBean(handlerName);
}
validateHandler(handler, request);
return buildPathExposingHandler(handler, urlPath, urlPath, null);
}
// 这里就是通过ant的方式,查找符合ant的匹配资源列表
List<String> matchingPatterns = new ArrayList<String>();
for (String registeredPattern : this.handlerMap.keySet()) {
if (getPathMatcher().match(registeredPattern, urlPath)) {
matchingPatterns.add(registeredPattern);
}
}
//当列表不为空,表示查找到符合的列表,然后按照ant规则,排序,越精确的越靠前
String bestPatternMatch = null;
Comparator<String> patternComparator = getPathMatcher().getPatternComparator(urlPath);
if (!matchingPatterns.isEmpty()) {
Collections.sort(matchingPatterns, patternComparator);
if (logger.isDebugEnabled()) {
logger.debug("Matching patterns for request [" + urlPath + "] are " + matchingPatterns);
}
bestPatternMatch = matchingPatterns.get(0);
}
if (bestPatternMatch != null) {
handler = this.handlerMap.get(bestPatternMatch);
// Bean name or resolved handler?
if (handler instanceof String) {
String handlerName = (String) handler;
handler = getApplicationContext().getBean(handlerName);
}
validateHandler(handler, request);
String pathWithinMapping = getPathMatcher().extractPathWithinPattern(bestPatternMatch, urlPath);
// There might be multiple 'best patterns', let's make sure we have the correct URI template variables
// for all of them
Map<String, String> uriTemplateVariables = new LinkedHashMap<String, String>();
for (String matchingPattern : matchingPatterns) {
if (patternComparator.compare(bestPatternMatch, matchingPattern) == 0) {
uriTemplateVariables
.putAll(getPathMatcher().extractUriTemplateVariables(matchingPattern, urlPath));
}
}
if (logger.isDebugEnabled()) {
logger.debug("URI Template variables for request [" + urlPath + "] are " + uriTemplateVariables);
}
return buildPathExposingHandler(handler, bestPatternMatch, pathWithinMapping, uriTemplateVariables);
}
// No handler found...
return null;
}
org.springframework.util.PathMatcher
org.springframework.util.AntPathMatcher.AntPatternComparator.AntPatternComparator
可以看下springmvc的通过url查找action的方法
Object org.springframework.web.servlet.handler.AbstractUrlHandlerMapping.getHandlerInternal(HttpServletRequest request) throws Exception
,这个方法的前面两行代码:
String lookupPath = this.urlPathHelper.getLookupPathForRequest(request);
Object handler = lookupHandler(lookupPath, request);
再看lookupHandler
Object org.springframework.web.servlet.handler.AbstractUrlHandlerMapping.lookupHandler(String urlPath, HttpServletRequest request) throws Exception
// 这里是绝对匹配,如我们的RequestMapping("/getView"),那么请求/test/getView,这种资源是可以绝对匹配上的,那么直接get就可以了。
Object handler = this.handlerMap.get(urlPath);
if (handler != null) {
// Bean name or resolved handler?
if (handler instanceof String) {
String handlerName = (String) handler;
handler = getApplicationContext().getBean(handlerName);
}
validateHandler(handler, request);
return buildPathExposingHandler(handler, urlPath, urlPath, null);
}
// 这里就是通过ant的方式,查找符合ant的匹配资源列表
List<String> matchingPatterns = new ArrayList<String>();
for (String registeredPattern : this.handlerMap.keySet()) {
if (getPathMatcher().match(registeredPattern, urlPath)) {
matchingPatterns.add(registeredPattern);
}
}
//当列表不为空,表示查找到符合的列表,然后按照ant规则,排序,越精确的越靠前
String bestPatternMatch = null;
Comparator<String> patternComparator = getPathMatcher().getPatternComparator(urlPath);
if (!matchingPatterns.isEmpty()) {
Collections.sort(matchingPatterns, patternComparator);
if (logger.isDebugEnabled()) {
logger.debug("Matching patterns for request [" + urlPath + "] are " + matchingPatterns);
}
bestPatternMatch = matchingPatterns.get(0);
}
if (bestPatternMatch != null) {
handler = this.handlerMap.get(bestPatternMatch);
// Bean name or resolved handler?
if (handler instanceof String) {
String handlerName = (String) handler;
handler = getApplicationContext().getBean(handlerName);
}
validateHandler(handler, request);
String pathWithinMapping = getPathMatcher().extractPathWithinPattern(bestPatternMatch, urlPath);
// There might be multiple 'best patterns', let's make sure we have the correct URI template variables
// for all of them
Map<String, String> uriTemplateVariables = new LinkedHashMap<String, String>();
for (String matchingPattern : matchingPatterns) {
if (patternComparator.compare(bestPatternMatch, matchingPattern) == 0) {
uriTemplateVariables
.putAll(getPathMatcher().extractUriTemplateVariables(matchingPattern, urlPath));
}
}
if (logger.isDebugEnabled()) {
logger.debug("URI Template variables for request [" + urlPath + "] are " + uriTemplateVariables);
}
return buildPathExposingHandler(handler, bestPatternMatch, pathWithinMapping, uriTemplateVariables);
}
// No handler found...
return null;
}
发表评论
-
Spring 定时任务,cron表达式,@Scheduled cron表达式
2016-04-25 15:48 5266一个cron表达式有至少6 ... -
spring mvc list
2015-12-14 10:28 1247我使用这样无法传入 @requestMapping(" ... -
Unable to locate Spring NamespaceHandler for XML schema namespace
2015-09-23 14:00 2290org.springframework.beans.facto ... -
关于使用s.url jstl的上下文
2015-08-16 13:28 884比如 [@s.url '/'/]index.html?cote ... -
Spring 属性占位符配置器 PropertyPlaceholderConfigurer
2015-08-02 12:43 2047<!-- 属性配置文件读 ... -
FactoryBean接口
2014-09-30 14:05 868实现了FactoryBean接口的bean不是简单的一个bea ... -
运行swing等可视化程序
2014-03-26 14:55 840Ant中调用的时候,总是一闪而过。 需要添加 <java ... -
国际化之MessageSourceAware和MessageSourceAccessor
2014-01-06 23:13 2820先看接口MessageSourceAware 该接口的注释中 ... -
spring 惯例优先原则
2013-07-22 09:46 1166惯例优先原则(convention over configur ... -
springmvc action方法中参数具有@ModelAttribute与不具有的区别
2012-12-14 09:36 4082在springmvc的参数解析中,发现具有@ModelAttr ... -
util包
2012-12-05 13:50 1068spring的util基本上都在springframework ... -
url,请求相关帮助类UrlPathHelper
2012-11-29 11:18 2487org.springframework.web.util.Ur ... -
整站国际化方案
2012-11-28 17:46 1074当前常见的实现方式,主要由两种方案实现 1.通过locale ... -
自定义任务
2012-11-21 22:33 1131<!-- 代码覆盖率任务定义,classpathref直 ... -
copy的时候,保持原有的目录结构
2012-11-21 17:31 1778flatten:用于指定是否需要复制目录,如果为true代表把 ... -
spring的三种注入方式
2012-11-20 17:30 18291.通过bean的property子元 ... -
给ant指定内存
2012-02-14 12:40 1190Windows操作系统,在运行ant的bat脚本文件: set ... -
spring AnnotationUtils 注解工具
2011-12-08 11:27 1270spring AnnotationUtils 注解工具 -
GenericCollectionTypeResolver,用于获取list或者map等元素的类型
2011-12-07 16:17 1272GenericCollectionTypeResolver,用 ... -
属性编辑器
2011-12-05 18:19 1055我自定义了一个类型,然后设置了一个属性编辑器,注册的class ...
相关推荐
详解Spring mvc ant path的使用方法 概要: 任何一个WEB都需要解决URL与请求处理器之间的映射,spring MVC也是一样,但Spring MVC就像Spring所作的一切一样(灵活,可以配置各种东西,但是也造成了很多复杂性),肯定...
该实用程序支持: /**/用于匹配零个或多个目录遍历自定义流包装器,例如myscheme://path/**/*.css 针对路径字符串匹配glob 通过全局过滤路径字符串数组如果glob包含无效语法,则为异常由于PHP的本机glob()函数效率更...
读目录一个Node.js实用程序模块,用于读取目录的内容,并支持Ant样式过滤以轻松排序结果-对任何特定于订单的构建系统特别有用。Node.js 使用npm npm install readdir然后与require一起使用,以进行同步使用: import...
ReadDecisionServer Zeuss 将短读数与索引的参考基因组对齐,并将模板的位置与掩模对齐... 您可以使用ant从源代码构建它,这会将Zeuss.jar文件写入/ dist。开始可以启动编译的服务器: java [-Djava.library.path={pa
path C:\ant196\bin classpath C:\ant196\lib 七、安装adt,下载ADT后解压,我们这里解压到C盘的adt-bundle-windows-x86-20140624目录。 运行eclipse,打开help,install new software,名称输入adt_plugin,adt...
注:在win7上,1.9.5可以和virtualbox 5.1.x版本相匹配,1.9.6以上的64位版本不能和 virtualbox正常配合 virtualbox4.3下载地址 vagrant1.9.5下载地址 添加本地box到vagrant(windows环境) 命令格式:vagrant box add...
o Apache Ant 1.6.5 or later for Linux and Mac, 1.7 or later for Windows o Not Not Not Not compatible with Gnu Compiler for Java (gcj) Note: Note: Note: Note: If JDK is already installed on your ...
4.7 匹配节点的模式 111 4.8 mode属性 113 4.9 内置的模板规则 114 4.10 对空白的处理 115 4.11 xpath语言 116 4.11.1 xpath上下文 116 4.11.2 位置路径 117 4.11.3 表达式 121 4.11.4 核心函数库 123 4.12...
4.7 匹配节点的模式 111 4.8 mode属性 113 4.9 内置的模板规则 114 4.10 对空白的处理 115 4.11 xpath语言 116 4.11.1 xpath上下文 116 4.11.2 位置路径 117 4.11.3 表达式 121 4.11.4 核心函数库 123 4.12...
4.7 匹配节点的模式 111 4.8 mode属性 113 4.9 内置的模板规则 114 4.10 对空白的处理 115 4.11 xpath语言 116 4.11.1 xpath上下文 116 4.11.2 位置路径 117 4.11.3 表达式 121 4.11.4 核心函数库 123 4.12...
4.7 匹配节点的模式 111 4.8 mode属性 113 4.9 内置的模板规则 114 4.10 对空白的处理 115 4.11 xpath语言 116 4.11.1 xpath上下文 116 4.11.2 位置路径 117 4.11.3 表达式 121 4.11.4 核心函数库 123 4.12...
4.3.2. ClassPathResource 4.3.3. FileSystemResource 4.3.4. ServletContextResource 4.3.5. InputStreamResource 4.3.6. ByteArrayResource 4.4. ResourceLoader 4.5. ResourceLoaderAware 接口 4.6. 把...