Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
57d327d1
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,发现更多精彩内容 >>
提交
57d327d1
编写于
4月 20, 2011
作者:
R
Rossen Stoyanchev
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
SPR-8255
上级
9c65973b
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
33 addition
and
9 deletion
+33
-9
org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestKey.java
...amework/web/servlet/mvc/method/annotation/RequestKey.java
+7
-6
org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ServletInvocableHandlerMethod.java
.../mvc/method/annotation/ServletInvocableHandlerMethod.java
+1
-1
org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestKeyTests.java
...rk/web/servlet/mvc/method/annotation/RequestKeyTests.java
+6
-2
org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerMethodMappingTests.java
...d/annotation/RequestMappingHandlerMethodMappingTests.java
+19
-0
未找到文件。
org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestKey.java
浏览文件 @
57d327d1
...
...
@@ -26,6 +26,7 @@ import java.util.Set;
import
javax.servlet.http.HttpServletRequest
;
import
org.springframework.util.PathMatcher
;
import
org.springframework.util.StringUtils
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.servlet.mvc.method.condition.RequestCondition
;
...
...
@@ -92,7 +93,7 @@ public final class RequestKey {
}
Set
<
String
>
result
=
new
LinkedHashSet
<
String
>(
patterns
.
size
());
for
(
String
pattern
:
patterns
)
{
if
(!
pattern
.
startsWith
(
"/"
))
{
if
(
StringUtils
.
hasLength
(
pattern
)
&&
!
pattern
.
startsWith
(
"/"
))
{
pattern
=
"/"
+
pattern
;
}
result
.
add
(
pattern
);
...
...
@@ -169,9 +170,9 @@ public final class RequestKey {
* <ul>
* <li>URL patterns:
* <ul>
* <li>If both
keys have path patterns combine them according to the rules of the given {@link PathMatcher}.
* <li>If either
key contains path patterns but not both use only what is available.
* <li>If neither
key contains path patterns use "/".
* <li>If both
have patterns combine them according to the rules of the given {@link PathMatcher}
* <li>If either
contains patterns, but not both, use the available pattern
* <li>If neither
contains patterns use ""
* </ul>
* <li>HTTP methods are combined as union of all HTTP methods listed in both keys.
* <li>Request parameter are combined into a logical AND.
...
...
@@ -198,8 +199,8 @@ public final class RequestKey {
Set
<
String
>
result
=
new
LinkedHashSet
<
String
>();
if
(!
typePatterns
.
isEmpty
()
&&
!
methodPatterns
.
isEmpty
())
{
for
(
String
pattern1
:
typePatterns
)
{
for
(
String
p2
:
methodPatterns
)
{
result
.
add
(
pathMatcher
.
combine
(
pattern1
,
p2
));
for
(
String
p
attern
2
:
methodPatterns
)
{
result
.
add
(
pathMatcher
.
combine
(
pattern1
,
p
attern
2
));
}
}
}
...
...
org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/mvc/method/annotation/ServletInvocableHandlerMethod.java
浏览文件 @
57d327d1
...
...
@@ -123,7 +123,7 @@ public class ServletInvocableHandlerMethod extends InvocableHandlerMethod {
webRequest
.
getResponse
().
sendError
(
this
.
responseStatus
.
value
(),
this
.
responseReason
);
}
else
{
webRequest
.
getResponse
().
se
ndError
(
this
.
responseStatus
.
value
());
webRequest
.
getResponse
().
se
tStatus
(
this
.
responseStatus
.
value
());
}
// to be picked up by the RedirectView
...
...
org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestKeyTests.java
浏览文件 @
57d327d1
...
...
@@ -77,9 +77,13 @@ public class RequestKeyTests {
key1
=
createKeyFromPatterns
();
key2
=
createKeyFromPatterns
();
key3
=
createKeyFromPatterns
(
"/"
);
key3
=
createKeyFromPatterns
(
""
);
assertEquals
(
key3
.
getPatterns
(),
key1
.
combine
(
key2
,
pathMatcher
).
getPatterns
());
key1
=
createKeyFromPatterns
(
"/t1"
);
key2
=
createKeyFromPatterns
(
""
);
key3
=
createKeyFromPatterns
(
"/t1"
);
assertEquals
(
key3
.
getPatterns
(),
key1
.
combine
(
key2
,
pathMatcher
).
getPatterns
());
}
@Test
...
...
org.springframework.web.servlet/src/test/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerMethodMappingTests.java
浏览文件 @
57d327d1
...
...
@@ -60,12 +60,15 @@ public class RequestMappingHandlerMethodMappingTests {
private
HandlerMethod
barMethod
;
private
HandlerMethod
emptyMethod
;
@Before
public
void
setUp
()
throws
Exception
{
handler
=
new
Handler
();
fooMethod
=
new
HandlerMethod
(
handler
,
"foo"
);
fooParamMethod
=
new
HandlerMethod
(
handler
,
"fooParam"
);
barMethod
=
new
HandlerMethod
(
handler
,
"bar"
);
emptyMethod
=
new
HandlerMethod
(
handler
,
"empty"
);
StaticApplicationContext
context
=
new
StaticApplicationContext
();
context
.
registerSingleton
(
"handler"
,
handler
.
getClass
());
...
...
@@ -88,6 +91,17 @@ public class RequestMappingHandlerMethodMappingTests {
assertEquals
(
barMethod
.
getMethod
(),
hm
.
getMethod
());
}
@Test
public
void
emptyPathMatch
()
throws
Exception
{
MockHttpServletRequest
request
=
new
MockHttpServletRequest
(
"GET"
,
""
);
HandlerMethod
hm
=
(
HandlerMethod
)
mapping
.
getHandler
(
request
).
getHandler
();
assertEquals
(
emptyMethod
.
getMethod
(),
hm
.
getMethod
());
request
=
new
MockHttpServletRequest
(
"GET"
,
"/"
);
hm
=
(
HandlerMethod
)
mapping
.
getHandler
(
request
).
getHandler
();
assertEquals
(
emptyMethod
.
getMethod
(),
hm
.
getMethod
());
}
// TODO: SPR-8247
@Ignore
@Test
...
...
@@ -144,6 +158,7 @@ public class RequestMappingHandlerMethodMappingTests {
@SuppressWarnings
(
"unused"
)
@Controller
@RequestMapping
private
static
class
Handler
{
@RequestMapping
(
value
=
"/foo"
,
method
=
RequestMethod
.
GET
)
...
...
@@ -157,6 +172,10 @@ public class RequestMappingHandlerMethodMappingTests {
@RequestMapping
(
value
=
"/ba*"
,
method
=
{
RequestMethod
.
GET
,
RequestMethod
.
HEAD
})
public
void
bar
()
{
}
@RequestMapping
(
value
=
""
)
public
void
empty
()
{
}
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录