Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
f36e8252
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,发现更多精彩内容 >>
提交
f36e8252
编写于
12月 07, 2009
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
polishing
上级
f72769a6
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
70 addition
and
82 deletion
+70
-82
org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/handler/AbstractUrlHandlerMapping.java
...mework/web/servlet/handler/AbstractUrlHandlerMapping.java
+10
-7
org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/handler/MappedInterceptor.java
...pringframework/web/servlet/handler/MappedInterceptor.java
+11
-7
org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/tags/form/AbstractCheckedElementTag.java
...work/web/servlet/tags/form/AbstractCheckedElementTag.java
+3
-4
org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/tags/form/AbstractMultiCheckedElementTag.java
...web/servlet/tags/form/AbstractMultiCheckedElementTag.java
+10
-7
org.springframework.web/src/main/java/org/springframework/http/converter/HttpMessageConverter.java
.../springframework/http/converter/HttpMessageConverter.java
+0
-4
org.springframework.web/src/main/java/org/springframework/web/bind/annotation/support/HandlerMethodInvoker.java
...ork/web/bind/annotation/support/HandlerMethodInvoker.java
+36
-53
未找到文件。
org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/handler/AbstractUrlHandlerMapping.java
浏览文件 @
f36e8252
...
...
@@ -22,7 +22,6 @@ import java.util.LinkedHashMap;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Set
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
...
...
@@ -72,7 +71,8 @@ public abstract class AbstractUrlHandlerMapping extends AbstractHandlerMapping {
private
final
Map
<
String
,
Object
>
handlerMap
=
new
LinkedHashMap
<
String
,
Object
>();
private
MappedInterceptors
mappedInterceptors
;
/**
* Set if URL lookup should always use the full path within the current servlet
* context. Else, the path within the current servlet mapping is used if applicable
...
...
@@ -164,10 +164,11 @@ public abstract class AbstractUrlHandlerMapping extends AbstractHandlerMapping {
@Override
protected
void
initInterceptors
()
{
super
.
initInterceptors
();
Map
<
String
,
MappedInterceptor
>
mappedInterceptors
=
BeanFactoryUtils
.
beansOfTypeIncludingAncestors
(
getApplicationContext
(),
MappedInterceptor
.
class
,
true
,
false
);
Map
<
String
,
MappedInterceptor
>
mappedInterceptors
=
BeanFactoryUtils
.
beansOfTypeIncludingAncestors
(
getApplicationContext
(),
MappedInterceptor
.
class
,
true
,
false
);
if
(!
mappedInterceptors
.
isEmpty
())
{
this
.
mappedInterceptors
=
new
MappedInterceptors
(
mappedInterceptors
.
values
().
toArray
(
new
MappedInterceptor
[
mappedInterceptors
.
size
()]));
this
.
mappedInterceptors
=
new
MappedInterceptors
(
mappedInterceptors
.
values
().
toArray
(
new
MappedInterceptor
[
mappedInterceptors
.
size
()]));
}
}
...
...
@@ -201,8 +202,9 @@ public abstract class AbstractUrlHandlerMapping extends AbstractHandlerMapping {
handler
=
buildPathExposingHandler
(
rawHandler
,
lookupPath
,
lookupPath
,
null
);
}
}
if
(
handler
!=
null
&
this
.
mappedInterceptors
!=
null
)
{
Set
<
HandlerInterceptor
>
mappedInterceptors
=
this
.
mappedInterceptors
.
getInterceptors
(
lookupPath
,
this
.
pathMatcher
);
if
(
handler
!=
null
&&
this
.
mappedInterceptors
!=
null
)
{
Set
<
HandlerInterceptor
>
mappedInterceptors
=
this
.
mappedInterceptors
.
getInterceptors
(
lookupPath
,
this
.
pathMatcher
);
if
(!
mappedInterceptors
.
isEmpty
())
{
HandlerExecutionChain
chain
;
if
(
handler
instanceof
HandlerExecutionChain
)
{
...
...
@@ -435,6 +437,7 @@ public abstract class AbstractUrlHandlerMapping extends AbstractHandlerMapping {
}
}
/**
* Special interceptor for exposing the
* {@link AbstractUrlHandlerMapping#URI_TEMPLATE_VARIABLES_ATTRIBUTE} attribute.
...
...
org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/handler/MappedInterceptor.java
浏览文件 @
f36e8252
...
...
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.springframework.web.servlet.handler
;
import
org.springframework.web.context.request.WebRequestInterceptor
;
...
...
@@ -20,6 +21,7 @@ import org.springframework.web.servlet.HandlerInterceptor;
/**
* Holds information about a HandlerInterceptor mapped to a path into the application.
*
* @author Keith Donald
* @since 3.0
*/
...
...
@@ -29,9 +31,10 @@ public final class MappedInterceptor {
private
final
HandlerInterceptor
interceptor
;
/**
* Create
s
a new mapped interceptor.
* @param pathPattern
the path pattern
* Create a new mapped interceptor.
* @param pathPattern
s the path patterns
* @param interceptor the interceptor
*/
public
MappedInterceptor
(
String
[]
pathPatterns
,
HandlerInterceptor
interceptor
)
{
...
...
@@ -40,8 +43,8 @@ public final class MappedInterceptor {
}
/**
* Create
s
a new mapped interceptor.
* @param pathPattern
the path pattern
* Create a new mapped interceptor.
* @param pathPattern
s the path patterns
* @param interceptor the interceptor
*/
public
MappedInterceptor
(
String
[]
pathPatterns
,
WebRequestInterceptor
interceptor
)
{
...
...
@@ -49,18 +52,19 @@ public final class MappedInterceptor {
this
.
interceptor
=
new
WebRequestHandlerInterceptorAdapter
(
interceptor
);
}
/**
* The path into the application the interceptor is mapped to.
*/
public
String
[]
getPathPatterns
()
{
return
pathPatterns
;
return
this
.
pathPatterns
;
}
/**
* The actual Interceptor reference.
*/
public
HandlerInterceptor
getInterceptor
()
{
return
interceptor
;
return
this
.
interceptor
;
}
}
\ No newline at end of file
}
org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/tags/form/AbstractCheckedElementTag.java
浏览文件 @
f36e8252
/*
* Copyright 2002-200
8
the original author or authors.
* Copyright 2002-200
9
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -17,7 +17,6 @@
package
org.springframework.web.servlet.tags.form
;
import
java.beans.PropertyEditor
;
import
javax.servlet.jsp.JspException
;
/**
...
...
@@ -52,7 +51,7 @@ public abstract class AbstractCheckedElementTag extends AbstractHtmlInputElement
tagWriter
.
writeAttribute
(
"checked"
,
"checked"
);
}
}
/**
* Determines whether the supplied value matched the selected value
* through delegating to {@link SelectedValueComparator#isSelected}.
...
...
@@ -68,7 +67,7 @@ public abstract class AbstractCheckedElementTag extends AbstractHtmlInputElement
*/
protected
void
renderFromBoolean
(
Boolean
boundValue
,
TagWriter
tagWriter
)
throws
JspException
{
tagWriter
.
writeAttribute
(
"value"
,
"true"
);
if
(
boundValue
.
booleanValue
()
)
{
if
(
boundValue
)
{
tagWriter
.
writeAttribute
(
"checked"
,
"checked"
);
}
}
...
...
org.springframework.web.servlet/src/main/java/org/springframework/web/servlet/tags/form/AbstractMultiCheckedElementTag.java
浏览文件 @
f36e8252
/*
* Copyright 2002-200
8
the original author or authors.
* Copyright 2002-200
9
the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
...
...
@@ -19,7 +19,6 @@ package org.springframework.web.servlet.tags.form;
import
java.util.Collection
;
import
java.util.Iterator
;
import
java.util.Map
;
import
javax.servlet.jsp.JspException
;
import
org.springframework.beans.BeanWrapper
;
...
...
@@ -103,13 +102,17 @@ public abstract class AbstractMultiCheckedElementTag extends AbstractCheckedElem
this
.
itemValue
=
itemValue
;
}
/**
* Get the name of the property mapped to the '<code>value</code>' attribute
* of the '<code>input type="checkbox/radio"</code>' tag.
*/
protected
String
getItemValue
()
{
return
this
.
itemValue
;
}
/**
* Set the value to be displayed as part
*
of the
'<code>input type="checkbox/radio"</code>' tag.
* Set the value to be displayed as part
of the
* '<code>input type="checkbox/radio"</code>' tag.
* <p>May be a runtime expression.
*/
public
void
setItemLabel
(
String
itemLabel
)
{
...
...
@@ -118,8 +121,8 @@ public abstract class AbstractMultiCheckedElementTag extends AbstractCheckedElem
}
/**
* Get the value to be displayed as part
*
of the
'<code>input type="checkbox/radio"</code>' tag.
* Get the value to be displayed as part
of the
* '<code>input type="checkbox/radio"</code>' tag.
*/
protected
String
getItemLabel
()
{
return
this
.
itemLabel
;
...
...
@@ -183,7 +186,7 @@ public abstract class AbstractMultiCheckedElementTag extends AbstractCheckedElem
@Override
protected
int
writeTagContent
(
TagWriter
tagWriter
)
throws
JspException
{
Object
items
=
getItems
();
Object
itemsObject
=
(
items
instanceof
String
?
evaluate
(
"items"
,
(
String
)
items
)
:
items
);
Object
itemsObject
=
(
items
instanceof
String
?
evaluate
(
"items"
,
items
)
:
items
);
String
itemValue
=
getItemValue
();
String
itemLabel
=
getItemLabel
();
...
...
org.springframework.web/src/main/java/org/springframework/http/converter/HttpMessageConverter.java
浏览文件 @
f36e8252
...
...
@@ -33,7 +33,6 @@ public interface HttpMessageConverter<T> {
/**
* Indicates whether the given class can be read by this converter.
*
* @param clazz the class to test for readability
* @param mediaType the media type to read, can be {@code null} if not specified
* @return <code>true</code> if readable; <code>false</code> otherwise
...
...
@@ -42,7 +41,6 @@ public interface HttpMessageConverter<T> {
/**
* Indicates whether the given class can be written by this converter.
*
* @param clazz the class to test for writability
* @param mediaType the media type to write, can be {@code null} if not specified
* @return <code>true</code> if writable; <code>false</code> otherwise
...
...
@@ -51,14 +49,12 @@ public interface HttpMessageConverter<T> {
/**
* Return the list of {@link MediaType} objects supported by this converter.
*
* @return the list of supported media types
*/
List
<
MediaType
>
getSupportedMediaTypes
();
/**
* Read an object of the given type form the given input message, and returns it.
*
* @param clazz the type of object to return. This type must have previously been passed to the {@link #canRead
* canRead} method of this interface, which must have returned {@code true}.
* @param inputMessage the HTTP input message to read from
...
...
org.springframework.web/src/main/java/org/springframework/web/bind/annotation/support/HandlerMethodInvoker.java
浏览文件 @
f36e8252
...
...
@@ -81,8 +81,8 @@ import org.springframework.web.context.request.WebRequest;
*
* @author Juergen Hoeller
* @author Arjen Poutsma
* @see #invokeHandlerMethod
* @since 2.5.2
* @see #invokeHandlerMethod
*/
public
class
HandlerMethodInvoker
{
...
...
@@ -103,6 +103,7 @@ public class HandlerMethodInvoker {
private
final
SimpleSessionStatus
sessionStatus
=
new
SimpleSessionStatus
();
public
HandlerMethodInvoker
(
HandlerMethodResolver
methodResolver
)
{
this
(
methodResolver
,
null
);
}
...
...
@@ -111,12 +112,9 @@ public class HandlerMethodInvoker {
this
(
methodResolver
,
bindingInitializer
,
new
DefaultSessionAttributeStore
(),
null
,
null
,
null
);
}
public
HandlerMethodInvoker
(
HandlerMethodResolver
methodResolver
,
WebBindingInitializer
bindingInitializer
,
SessionAttributeStore
sessionAttributeStore
,
ParameterNameDiscoverer
parameterNameDiscoverer
,
WebArgumentResolver
[]
customArgumentResolvers
,
HttpMessageConverter
[]
messageConverters
)
{
public
HandlerMethodInvoker
(
HandlerMethodResolver
methodResolver
,
WebBindingInitializer
bindingInitializer
,
SessionAttributeStore
sessionAttributeStore
,
ParameterNameDiscoverer
parameterNameDiscoverer
,
WebArgumentResolver
[]
customArgumentResolvers
,
HttpMessageConverter
[]
messageConverters
)
{
this
.
methodResolver
=
methodResolver
;
this
.
bindingInitializer
=
bindingInitializer
;
...
...
@@ -126,10 +124,9 @@ public class HandlerMethodInvoker {
this
.
messageConverters
=
messageConverters
;
}
public
final
Object
invokeHandlerMethod
(
Method
handlerMethod
,
Object
handler
,
NativeWebRequest
webRequest
,
ExtendedModelMap
implicitModel
)
throws
Exception
{
public
final
Object
invokeHandlerMethod
(
Method
handlerMethod
,
Object
handler
,
NativeWebRequest
webRequest
,
ExtendedModelMap
implicitModel
)
throws
Exception
{
Method
handlerMethodToInvoke
=
BridgeMethodResolver
.
findBridgedMethod
(
handlerMethod
);
try
{
...
...
@@ -174,10 +171,8 @@ public class HandlerMethodInvoker {
}
@SuppressWarnings
(
"unchecked"
)
private
Object
[]
resolveHandlerArguments
(
Method
handlerMethod
,
Object
handler
,
NativeWebRequest
webRequest
,
ExtendedModelMap
implicitModel
)
throws
Exception
{
private
Object
[]
resolveHandlerArguments
(
Method
handlerMethod
,
Object
handler
,
NativeWebRequest
webRequest
,
ExtendedModelMap
implicitModel
)
throws
Exception
{
Class
[]
paramTypes
=
handlerMethod
.
getParameterTypes
();
Object
[]
args
=
new
Object
[
paramTypes
.
length
];
...
...
@@ -340,10 +335,8 @@ public class HandlerMethodInvoker {
}
}
private
Object
[]
resolveInitBinderArguments
(
Object
handler
,
Method
initBinderMethod
,
WebDataBinder
binder
,
NativeWebRequest
webRequest
)
throws
Exception
{
private
Object
[]
resolveInitBinderArguments
(
Object
handler
,
Method
initBinderMethod
,
WebDataBinder
binder
,
NativeWebRequest
webRequest
)
throws
Exception
{
Class
[]
initBinderParams
=
initBinderMethod
.
getParameterTypes
();
Object
[]
initBinderArgs
=
new
Object
[
initBinderParams
.
length
];
...
...
@@ -410,12 +403,9 @@ public class HandlerMethodInvoker {
}
@SuppressWarnings
(
"unchecked"
)
private
Object
resolveRequestParam
(
String
paramName
,
boolean
required
,
String
defaultValue
,
MethodParameter
methodParam
,
NativeWebRequest
webRequest
,
Object
handlerForInitBinderCall
)
throws
Exception
{
private
Object
resolveRequestParam
(
String
paramName
,
boolean
required
,
String
defaultValue
,
MethodParameter
methodParam
,
NativeWebRequest
webRequest
,
Object
handlerForInitBinderCall
)
throws
Exception
{
Class
<?>
paramType
=
methodParam
.
getParameterType
();
if
(
Map
.
class
.
isAssignableFrom
(
paramType
))
{
...
...
@@ -471,12 +461,9 @@ public class HandlerMethodInvoker {
}
@SuppressWarnings
(
"unchecked"
)
private
Object
resolveRequestHeader
(
String
headerName
,
boolean
required
,
String
defaultValue
,
MethodParameter
methodParam
,
NativeWebRequest
webRequest
,
Object
handlerForInitBinderCall
)
throws
Exception
{
private
Object
resolveRequestHeader
(
String
headerName
,
boolean
required
,
String
defaultValue
,
MethodParameter
methodParam
,
NativeWebRequest
webRequest
,
Object
handlerForInitBinderCall
)
throws
Exception
{
Class
<?>
paramType
=
methodParam
.
getParameterType
();
if
(
Map
.
class
.
isAssignableFrom
(
paramType
))
{
...
...
@@ -532,7 +519,9 @@ public class HandlerMethodInvoker {
}
}
/** Resolves the given {@link RequestBody @RequestBody} annotation. */
/**
* Resolves the given {@link RequestBody @RequestBody} annotation.
*/
@SuppressWarnings
(
"unchecked"
)
protected
Object
resolveRequestBody
(
MethodParameter
methodParam
,
NativeWebRequest
webRequest
,
Object
handler
)
throws
Exception
{
...
...
@@ -563,8 +552,8 @@ public class HandlerMethodInvoker {
}
/**
* Return a {@link HttpInputMessage} for the given {@link NativeWebRequest}.
Throws an UnsupportedOperationException by
* default.
* Return a {@link HttpInputMessage} for the given {@link NativeWebRequest}.
*
<p>Throws an UnsupportedOperationException by
default.
*/
protected
HttpInputMessage
createHttpInputMessage
(
NativeWebRequest
webRequest
)
throws
Exception
{
throw
new
UnsupportedOperationException
(
"@RequestBody not supported"
);
...
...
@@ -596,7 +585,10 @@ public class HandlerMethodInvoker {
return
binder
.
convertIfNecessary
(
cookieValue
,
paramType
,
methodParam
);
}
/** Resolves the given {@link CookieValue @CookieValue} annotation. Throws an UnsupportedOperationException by default. */
/**
* Resolves the given {@link CookieValue @CookieValue} annotation.
* <p>Throws an UnsupportedOperationException by default.
*/
protected
Object
resolveCookieValue
(
String
cookieName
,
Class
paramType
,
NativeWebRequest
webRequest
)
throws
Exception
{
...
...
@@ -619,8 +611,8 @@ public class HandlerMethodInvoker {
}
/**
* Resolves the given {@link PathVariable @PathVariable} annotation.
Throws an UnsupportedOperationException by
* default.
* Resolves the given {@link PathVariable @PathVariable} annotation.
*
<p>Throws an UnsupportedOperationException by
default.
*/
protected
String
resolvePathVariable
(
String
pathVarName
,
Class
paramType
,
NativeWebRequest
webRequest
)
throws
Exception
{
...
...
@@ -652,11 +644,8 @@ public class HandlerMethodInvoker {
return
value
;
}
private
WebRequestDataBinder
resolveModelAttribute
(
String
attrName
,
MethodParameter
methodParam
,
ExtendedModelMap
implicitModel
,
NativeWebRequest
webRequest
,
Object
handler
)
throws
Exception
{
private
WebRequestDataBinder
resolveModelAttribute
(
String
attrName
,
MethodParameter
methodParam
,
ExtendedModelMap
implicitModel
,
NativeWebRequest
webRequest
,
Object
handler
)
throws
Exception
{
// Bind request parameter onto object...
String
name
=
attrName
;
...
...
@@ -683,10 +672,8 @@ public class HandlerMethodInvoker {
}
@SuppressWarnings
(
"unchecked"
)
public
final
void
updateModelAttributes
(
Object
handler
,
Map
<
String
,
Object
>
mavModel
,
ExtendedModelMap
implicitModel
,
NativeWebRequest
webRequest
)
throws
Exception
{
public
final
void
updateModelAttributes
(
Object
handler
,
Map
<
String
,
Object
>
mavModel
,
ExtendedModelMap
implicitModel
,
NativeWebRequest
webRequest
)
throws
Exception
{
if
(
this
.
methodResolver
.
hasSessionAttributes
()
&&
this
.
sessionStatus
.
isComplete
())
{
for
(
String
attrName
:
this
.
methodResolver
.
getActualSessionAttributeNames
())
{
...
...
@@ -753,9 +740,7 @@ public class HandlerMethodInvoker {
throw
new
IllegalStateException
(
message
);
}
protected
void
doBind
(
WebRequestDataBinder
binder
,
NativeWebRequest
webRequest
,
boolean
validate
,
protected
void
doBind
(
WebRequestDataBinder
binder
,
NativeWebRequest
webRequest
,
boolean
validate
,
boolean
failOnErrors
)
throws
Exception
{
binder
.
bind
(
webRequest
);
...
...
@@ -803,10 +788,8 @@ public class HandlerMethodInvoker {
return
WebArgumentResolver
.
UNRESOLVED
;
}
protected
final
void
addReturnValueAsModelAttribute
(
Method
handlerMethod
,
Class
handlerType
,
Object
returnValue
,
ExtendedModelMap
implicitModel
)
{
protected
final
void
addReturnValueAsModelAttribute
(
Method
handlerMethod
,
Class
handlerType
,
Object
returnValue
,
ExtendedModelMap
implicitModel
)
{
ModelAttribute
attr
=
AnnotationUtils
.
findAnnotation
(
handlerMethod
,
ModelAttribute
.
class
);
String
attrName
=
(
attr
!=
null
?
attr
.
value
()
:
""
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录