Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
25a5d9d7
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,发现更多精彩内容 >>
提交
25a5d9d7
编写于
5月 31, 2015
作者:
S
Sam Brannen
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Introduce alias for 'value' attribute in @RequestHeader
Issue: SPR-11393
上级
c4c3ce79
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
22 addition
and
10 deletion
+22
-10
spring-web/src/main/java/org/springframework/web/bind/annotation/RequestHeader.java
...rg/springframework/web/bind/annotation/RequestHeader.java
+15
-3
spring-web/src/main/java/org/springframework/web/bind/annotation/support/HandlerMethodInvoker.java
...ork/web/bind/annotation/support/HandlerMethodInvoker.java
+1
-1
spring-web/src/main/java/org/springframework/web/method/annotation/RequestHeaderMethodArgumentResolver.java
...ethod/annotation/RequestHeaderMethodArgumentResolver.java
+2
-2
spring-web/src/test/java/org/springframework/web/method/annotation/RequestHeaderMethodArgumentResolverTests.java
.../annotation/RequestHeaderMethodArgumentResolverTests.java
+4
-4
未找到文件。
spring-web/src/main/java/org/springframework/web/bind/annotation/RequestHeader.java
浏览文件 @
25a5d9d7
/*
/*
* Copyright 2002-201
4
the original author or authors.
* Copyright 2002-201
5
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -22,9 +22,12 @@ import java.lang.annotation.Retention;
...
@@ -22,9 +22,12 @@ import java.lang.annotation.Retention;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.RetentionPolicy
;
import
java.lang.annotation.Target
;
import
java.lang.annotation.Target
;
import
org.springframework.core.annotation.AliasFor
;
/**
/**
* Annotation which indicates that a method parameter should be bound to a web request header.
* Annotation which indicates that a method parameter should be bound to a web request header.
* Supported for annotated handler methods in Servlet and Portlet environments.
*
* <p>Supported for annotated handler methods in Servlet and Portlet environments.
*
*
* <p>If the method parameter is {@link java.util.Map Map<String, String>} or
* <p>If the method parameter is {@link java.util.Map Map<String, String>} or
* {@link org.springframework.util.MultiValueMap MultiValueMap<String, String>},
* {@link org.springframework.util.MultiValueMap MultiValueMap<String, String>},
...
@@ -32,6 +35,7 @@ import java.lang.annotation.Target;
...
@@ -32,6 +35,7 @@ import java.lang.annotation.Target;
* populated with all header names and values.
* populated with all header names and values.
*
*
* @author Juergen Hoeller
* @author Juergen Hoeller
* @author Sam Brannen
* @since 3.0
* @since 3.0
* @see RequestMapping
* @see RequestMapping
* @see RequestParam
* @see RequestParam
...
@@ -45,10 +49,18 @@ import java.lang.annotation.Target;
...
@@ -45,10 +49,18 @@ import java.lang.annotation.Target;
public
@interface
RequestHeader
{
public
@interface
RequestHeader
{
/**
/**
*
The name of the request header to bind to
.
*
Alias for {@link #name}
.
*/
*/
@AliasFor
(
attribute
=
"name"
)
String
value
()
default
""
;
String
value
()
default
""
;
/**
* The name of the request header to bind to.
* @since 4.2
*/
@AliasFor
(
attribute
=
"value"
)
String
name
()
default
""
;
/**
/**
* Whether the header is required.
* Whether the header is required.
* <p>Default is {@code true}, leading to an exception thrown in case
* <p>Default is {@code true}, leading to an exception thrown in case
...
...
spring-web/src/main/java/org/springframework/web/bind/annotation/support/HandlerMethodInvoker.java
浏览文件 @
25a5d9d7
...
@@ -267,7 +267,7 @@ public class HandlerMethodInvoker {
...
@@ -267,7 +267,7 @@ public class HandlerMethodInvoker {
}
}
else
if
(
RequestHeader
.
class
.
isInstance
(
paramAnn
))
{
else
if
(
RequestHeader
.
class
.
isInstance
(
paramAnn
))
{
RequestHeader
requestHeader
=
(
RequestHeader
)
paramAnn
;
RequestHeader
requestHeader
=
(
RequestHeader
)
paramAnn
;
headerName
=
requestHeader
.
valu
e
();
headerName
=
requestHeader
.
nam
e
();
required
=
requestHeader
.
required
();
required
=
requestHeader
.
required
();
defaultValue
=
parseDefaultValueAttribute
(
requestHeader
.
defaultValue
());
defaultValue
=
parseDefaultValueAttribute
(
requestHeader
.
defaultValue
());
annotationsFound
++;
annotationsFound
++;
...
...
spring-web/src/main/java/org/springframework/web/method/annotation/RequestHeaderMethodArgumentResolver.java
浏览文件 @
25a5d9d7
/*
/*
* Copyright 2002-201
4
the original author or authors.
* Copyright 2002-201
5
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -86,7 +86,7 @@ public class RequestHeaderMethodArgumentResolver extends AbstractNamedValueMetho
...
@@ -86,7 +86,7 @@ public class RequestHeaderMethodArgumentResolver extends AbstractNamedValueMetho
private
static
class
RequestHeaderNamedValueInfo
extends
NamedValueInfo
{
private
static
class
RequestHeaderNamedValueInfo
extends
NamedValueInfo
{
private
RequestHeaderNamedValueInfo
(
RequestHeader
annotation
)
{
private
RequestHeaderNamedValueInfo
(
RequestHeader
annotation
)
{
super
(
annotation
.
valu
e
(),
annotation
.
required
(),
annotation
.
defaultValue
());
super
(
annotation
.
nam
e
(),
annotation
.
required
(),
annotation
.
defaultValue
());
}
}
}
}
...
...
spring-web/src/test/java/org/springframework/web/method/annotation/RequestHeaderMethodArgumentResolverTests.java
浏览文件 @
25a5d9d7
/*
/*
* Copyright 2002-201
2
the original author or authors.
* Copyright 2002-201
5
the original author or authors.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* you may not use this file except in compliance with the License.
...
@@ -141,10 +141,10 @@ public class RequestHeaderMethodArgumentResolverTests {
...
@@ -141,10 +141,10 @@ public class RequestHeaderMethodArgumentResolverTests {
resolver
.
resolveArgument
(
paramNamedValueStringArray
,
null
,
webRequest
,
null
);
resolver
.
resolveArgument
(
paramNamedValueStringArray
,
null
,
webRequest
,
null
);
}
}
public
void
params
(
@RequestHeader
(
valu
e
=
"name"
,
defaultValue
=
"bar"
)
String
param1
,
public
void
params
(
@RequestHeader
(
nam
e
=
"name"
,
defaultValue
=
"bar"
)
String
param1
,
@RequestHeader
(
"name"
)
String
[]
param2
,
@RequestHeader
(
"name"
)
String
[]
param2
,
@RequestHeader
(
valu
e
=
"name"
,
defaultValue
=
"#{systemProperties.systemProperty}"
)
String
param3
,
@RequestHeader
(
nam
e
=
"name"
,
defaultValue
=
"#{systemProperties.systemProperty}"
)
String
param3
,
@RequestHeader
(
valu
e
=
"name"
,
defaultValue
=
"#{request.contextPath}"
)
String
param4
,
@RequestHeader
(
nam
e
=
"name"
,
defaultValue
=
"#{request.contextPath}"
)
String
param4
,
@RequestHeader
(
"name"
)
Map
<?,
?>
unsupported
)
{
@RequestHeader
(
"name"
)
Map
<?,
?>
unsupported
)
{
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录