Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
39a97a61
S
spring-framework
项目概览
爱吃血肠
/
spring-framework
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
spring-framework
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
39a97a61
编写于
9月 25, 2009
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
resolve handler bean name early; validate header conditions as well
上级
aec2bc09
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
26 addition
and
10 deletion
+26
-10
org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/handler/AbstractUrlHandlerMapping.java
...mework/web/servlet/handler/AbstractUrlHandlerMapping.java
+16
-6
org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/mvc/annotation/DefaultAnnotationHandlerMapping.java
...rvlet/mvc/annotation/DefaultAnnotationHandlerMapping.java
+10
-4
未找到文件。
org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/handler/AbstractUrlHandlerMapping.java
浏览文件 @
39a97a61
...
...
@@ -170,6 +170,11 @@ public abstract class AbstractUrlHandlerMapping extends AbstractHandlerMapping {
rawHandler
=
getDefaultHandler
();
}
if
(
rawHandler
!=
null
)
{
// Bean name or resolved handler?
if
(
rawHandler
instanceof
String
)
{
String
handlerName
=
(
String
)
rawHandler
;
rawHandler
=
getApplicationContext
().
getBean
(
handlerName
);
}
validateHandler
(
rawHandler
,
request
);
handler
=
buildPathExposingHandler
(
rawHandler
,
lookupPath
,
null
);
}
...
...
@@ -200,6 +205,11 @@ public abstract class AbstractUrlHandlerMapping extends AbstractHandlerMapping {
// Direct match?
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
,
null
);
}
...
...
@@ -213,6 +223,11 @@ public abstract class AbstractUrlHandlerMapping extends AbstractHandlerMapping {
}
if
(
bestPathMatch
!=
null
)
{
handler
=
this
.
handlerMap
.
get
(
bestPathMatch
);
// Bean name or resolved handler?
if
(
handler
instanceof
String
)
{
String
handlerName
=
(
String
)
handler
;
handler
=
getApplicationContext
().
getBean
(
handlerName
);
}
validateHandler
(
handler
,
request
);
String
pathWithinMapping
=
getPathMatcher
().
extractPathWithinPattern
(
bestPathMatch
,
urlPath
);
Map
<
String
,
String
>
uriTemplateVariables
=
...
...
@@ -248,11 +263,6 @@ public abstract class AbstractUrlHandlerMapping extends AbstractHandlerMapping {
protected
Object
buildPathExposingHandler
(
Object
rawHandler
,
String
pathWithinMapping
,
Map
<
String
,
String
>
uriTemplateVariables
)
{
// Bean name or resolved handler?
if
(
rawHandler
instanceof
String
)
{
String
handlerName
=
(
String
)
rawHandler
;
rawHandler
=
getApplicationContext
().
getBean
(
handlerName
);
}
HandlerExecutionChain
chain
=
new
HandlerExecutionChain
(
rawHandler
);
chain
.
addInterceptor
(
new
PathExposingHandlerInterceptor
(
pathWithinMapping
));
if
(!
CollectionUtils
.
isEmpty
(
uriTemplateVariables
))
{
...
...
@@ -353,7 +363,7 @@ public abstract class AbstractUrlHandlerMapping extends AbstractHandlerMapping {
* as value.
* @see #getDefaultHandler()
*/
public
final
Map
getHandlerMap
()
{
public
final
Map
<
String
,
Object
>
getHandlerMap
()
{
return
Collections
.
unmodifiableMap
(
this
.
handlerMap
);
}
...
...
org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/mvc/annotation/DefaultAnnotationHandlerMapping.java
浏览文件 @
39a97a61
...
...
@@ -30,6 +30,7 @@ import org.springframework.stereotype.Controller;
import
org.springframework.util.ReflectionUtils
;
import
org.springframework.util.StringUtils
;
import
org.springframework.web.HttpRequestMethodNotSupportedException
;
import
org.springframework.web.bind.ServletRequestBindingException
;
import
org.springframework.web.bind.UnsatisfiedServletRequestParameterException
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
...
...
@@ -186,11 +187,9 @@ public class DefaultAnnotationHandlerMapping extends AbstractDetectingUrlHandler
*/
@Override
protected
void
validateHandler
(
Object
handler
,
HttpServletRequest
request
)
throws
Exception
{
Class
handlerClass
=
(
handler
instanceof
String
?
getApplicationContext
().
getType
((
String
)
handler
)
:
handler
.
getClass
());
RequestMapping
mapping
=
this
.
cachedMappings
.
get
(
handlerClass
);
RequestMapping
mapping
=
this
.
cachedMappings
.
get
(
handler
.
getClass
());
if
(
mapping
==
null
)
{
mapping
=
AnnotationUtils
.
findAnnotation
(
handler
Class
,
RequestMapping
.
class
);
mapping
=
AnnotationUtils
.
findAnnotation
(
handler
.
getClass
()
,
RequestMapping
.
class
);
}
if
(
mapping
!=
null
)
{
validateMapping
(
mapping
,
request
);
...
...
@@ -218,6 +217,13 @@ public class DefaultAnnotationHandlerMapping extends AbstractDetectingUrlHandler
if
(!
ServletAnnotationMappingUtils
.
checkParameters
(
mappedParams
,
request
))
{
throw
new
UnsatisfiedServletRequestParameterException
(
mappedParams
,
request
.
getParameterMap
());
}
String
[]
mappedHeaders
=
mapping
.
headers
();
if
(!
ServletAnnotationMappingUtils
.
checkHeaders
(
mappedHeaders
,
request
))
{
throw
new
ServletRequestBindingException
(
"Header conditions \""
+
StringUtils
.
arrayToDelimitedString
(
mappedHeaders
,
", "
)
+
"\" not met for actual request"
);
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录