Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
普通程序员一名
spring-framework
提交
6027cf22
S
spring-framework
项目概览
普通程序员一名
/
spring-framework
与 Fork 源项目一致
从无法访问的项目Fork
通知
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,发现更多精彩内容 >>
提交
6027cf22
编写于
8月 14, 2018
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Polishing
上级
c0c9e08b
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
33 addition
and
44 deletion
+33
-44
spring-web/src/main/java/org/springframework/web/method/support/ModelAndViewContainer.java
...ngframework/web/method/support/ModelAndViewContainer.java
+3
-3
spring-webmvc/src/main/java/org/springframework/web/servlet/DispatcherServlet.java
...va/org/springframework/web/servlet/DispatcherServlet.java
+5
-9
spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/support/DefaultHandlerExceptionResolver.java
.../servlet/mvc/support/DefaultHandlerExceptionResolver.java
+22
-21
spring-webmvc/src/main/java/org/springframework/web/servlet/view/AbstractView.java
...va/org/springframework/web/servlet/view/AbstractView.java
+1
-2
spring-webmvc/src/main/java/org/springframework/web/servlet/view/xml/MappingJackson2XmlView.java
...ramework/web/servlet/view/xml/MappingJackson2XmlView.java
+2
-9
未找到文件。
spring-web/src/main/java/org/springframework/web/method/support/ModelAndViewContainer.java
浏览文件 @
6027cf22
...
...
@@ -172,9 +172,9 @@ public class ModelAndViewContainer {
/**
* Provide a separate model instance to use in a redirect scenario.
* The provided additional model however is not used unless
* {@link #setRedirectModelScenario
(boolean)} gets set to {@code true} to signal
*
a
redirect scenario.
*
<p>
The provided additional model however is not used unless
* {@link #setRedirectModelScenario
} gets set to {@code true}
*
to signal an actual
redirect scenario.
*/
public
void
setRedirectModel
(
ModelMap
redirectModel
)
{
this
.
redirectModel
=
redirectModel
;
...
...
spring-webmvc/src/main/java/org/springframework/web/servlet/DispatcherServlet.java
浏览文件 @
6027cf22
...
...
@@ -906,7 +906,6 @@ public class DispatcherServlet extends FrameworkServlet {
*/
@Override
protected
void
doService
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
Exception
{
logRequest
(
request
);
// Keep a snapshot of the request attributes in case of an include,
...
...
@@ -953,7 +952,6 @@ public class DispatcherServlet extends FrameworkServlet {
private
void
logRequest
(
HttpServletRequest
request
)
{
if
(
logger
.
isDebugEnabled
())
{
String
params
;
if
(
isEnableLoggingRequestDetails
())
{
params
=
request
.
getParameterMap
().
entrySet
().
stream
()
...
...
@@ -961,16 +959,14 @@ public class DispatcherServlet extends FrameworkServlet {
.
collect
(
Collectors
.
joining
(
", "
));
}
else
{
params
=
request
.
getParameterMap
().
isEmpty
()
?
""
:
"masked"
;
params
=
(
request
.
getParameterMap
().
isEmpty
()
?
""
:
"masked"
)
;
}
String
query
=
StringUtils
.
isEmpty
(
request
.
getQueryString
())
?
""
:
"?"
+
request
.
getQueryString
();
String
dispatchType
=
!
request
.
getDispatcherType
().
equals
(
DispatcherType
.
REQUEST
)
?
"\""
+
request
.
getDispatcherType
().
name
()
+
"\" dispatch for "
:
""
;
String
message
=
dispatchType
+
request
.
getMethod
()
+
" \""
+
getRequestUri
(
request
)
+
query
+
"\", parameters={"
+
params
+
"}"
;
String
dispatchType
=
(!
request
.
getDispatcherType
().
equals
(
DispatcherType
.
REQUEST
)
?
"\""
+
request
.
getDispatcherType
().
name
()
+
"\" dispatch for "
:
""
);
String
message
=
(
dispatchType
+
request
.
getMethod
()
+
" \""
+
getRequestUri
(
request
)
+
query
+
"\", parameters={"
+
params
+
"}"
);
if
(
logger
.
isTraceEnabled
())
{
List
<
String
>
values
=
Collections
.
list
(
request
.
getHeaderNames
());
...
...
spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/support/DefaultHandlerExceptionResolver.java
浏览文件 @
6027cf22
...
...
@@ -247,7 +247,7 @@ public class DefaultHandlerExceptionResolver extends AbstractHandlerExceptionRes
* @param handler the executed handler, or {@code null} if none chosen
* at the time of the exception (for example, if multipart resolution failed)
* @return an empty ModelAndView indicating the exception was handled
* @throws IOException potentially thrown from
response.sendError()
* @throws IOException potentially thrown from
{@link HttpServletResponse#sendError}
*/
protected
ModelAndView
handleHttpRequestMethodNotSupported
(
HttpRequestMethodNotSupportedException
ex
,
HttpServletRequest
request
,
HttpServletResponse
response
,
@Nullable
Object
handler
)
throws
IOException
{
...
...
@@ -272,7 +272,7 @@ public class DefaultHandlerExceptionResolver extends AbstractHandlerExceptionRes
* @param response current HTTP response
* @param handler the executed handler
* @return an empty ModelAndView indicating the exception was handled
* @throws IOException potentially thrown from
response.sendError()
* @throws IOException potentially thrown from
{@link HttpServletResponse#sendError}
*/
protected
ModelAndView
handleHttpMediaTypeNotSupported
(
HttpMediaTypeNotSupportedException
ex
,
HttpServletRequest
request
,
HttpServletResponse
response
,
@Nullable
Object
handler
)
throws
IOException
{
...
...
@@ -296,7 +296,7 @@ public class DefaultHandlerExceptionResolver extends AbstractHandlerExceptionRes
* @param response current HTTP response
* @param handler the executed handler
* @return an empty ModelAndView indicating the exception was handled
* @throws IOException potentially thrown from
response.sendError()
* @throws IOException potentially thrown from
{@link HttpServletResponse#sendError}
*/
protected
ModelAndView
handleHttpMediaTypeNotAcceptable
(
HttpMediaTypeNotAcceptableException
ex
,
HttpServletRequest
request
,
HttpServletResponse
response
,
@Nullable
Object
handler
)
throws
IOException
{
...
...
@@ -315,7 +315,7 @@ public class DefaultHandlerExceptionResolver extends AbstractHandlerExceptionRes
* @param response current HTTP response
* @param handler the executed handler
* @return an empty ModelAndView indicating the exception was handled
* @throws IOException potentially thrown from
response.sendError()
* @throws IOException potentially thrown from
{@link HttpServletResponse#sendError}
* @since 4.2
*/
protected
ModelAndView
handleMissingPathVariable
(
MissingPathVariableException
ex
,
...
...
@@ -335,7 +335,7 @@ public class DefaultHandlerExceptionResolver extends AbstractHandlerExceptionRes
* @param response current HTTP response
* @param handler the executed handler
* @return an empty ModelAndView indicating the exception was handled
* @throws IOException potentially thrown from
response.sendError()
* @throws IOException potentially thrown from
{@link HttpServletResponse#sendError}
*/
protected
ModelAndView
handleMissingServletRequestParameter
(
MissingServletRequestParameterException
ex
,
HttpServletRequest
request
,
HttpServletResponse
response
,
@Nullable
Object
handler
)
throws
IOException
{
...
...
@@ -353,7 +353,7 @@ public class DefaultHandlerExceptionResolver extends AbstractHandlerExceptionRes
* @param response current HTTP response
* @param handler the executed handler
* @return an empty ModelAndView indicating the exception was handled
* @throws IOException potentially thrown from
response.sendError()
* @throws IOException potentially thrown from
{@link HttpServletResponse#sendError}
*/
protected
ModelAndView
handleServletRequestBindingException
(
ServletRequestBindingException
ex
,
HttpServletRequest
request
,
HttpServletResponse
response
,
@Nullable
Object
handler
)
throws
IOException
{
...
...
@@ -371,7 +371,7 @@ public class DefaultHandlerExceptionResolver extends AbstractHandlerExceptionRes
* @param response current HTTP response
* @param handler the executed handler
* @return an empty ModelAndView indicating the exception was handled
* @throws IOException potentially thrown from
response.sendError()
* @throws IOException potentially thrown from
{@link HttpServletResponse#sendError}
*/
protected
ModelAndView
handleConversionNotSupported
(
ConversionNotSupportedException
ex
,
HttpServletRequest
request
,
HttpServletResponse
response
,
@Nullable
Object
handler
)
throws
IOException
{
...
...
@@ -392,7 +392,7 @@ public class DefaultHandlerExceptionResolver extends AbstractHandlerExceptionRes
* @param response current HTTP response
* @param handler the executed handler
* @return an empty ModelAndView indicating the exception was handled
* @throws IOException potentially thrown from
response.sendError()
* @throws IOException potentially thrown from
{@link HttpServletResponse#sendError}
*/
protected
ModelAndView
handleTypeMismatch
(
TypeMismatchException
ex
,
HttpServletRequest
request
,
HttpServletResponse
response
,
@Nullable
Object
handler
)
throws
IOException
{
...
...
@@ -415,7 +415,7 @@ public class DefaultHandlerExceptionResolver extends AbstractHandlerExceptionRes
* @param response current HTTP response
* @param handler the executed handler
* @return an empty ModelAndView indicating the exception was handled
* @throws IOException potentially thrown from
response.sendError()
* @throws IOException potentially thrown from
{@link HttpServletResponse#sendError}
*/
protected
ModelAndView
handleHttpMessageNotReadable
(
HttpMessageNotReadableException
ex
,
HttpServletRequest
request
,
HttpServletResponse
response
,
@Nullable
Object
handler
)
throws
IOException
{
...
...
@@ -428,17 +428,18 @@ public class DefaultHandlerExceptionResolver extends AbstractHandlerExceptionRes
}
/**
* Handle the case where a {@linkplain org.springframework.http.converter.HttpMessageConverter message converter}
* Handle the case where a
* {@linkplain org.springframework.http.converter.HttpMessageConverter message converter}
* cannot write to a HTTP request.
* <p>The default implementation sends an HTTP 500 error, and returns an empty {@code ModelAndView}.
* Alternatively, a fallback view could be chosen, or the HttpMediaTypeNotSupportedException could
be
* rethrown as-is.
* Alternatively, a fallback view could be chosen, or the HttpMediaTypeNotSupportedException could
*
be
rethrown as-is.
* @param ex the HttpMessageNotWritableException to be handled
* @param request current HTTP request
* @param response current HTTP response
* @param handler the executed handler
* @return an empty ModelAndView indicating the exception was handled
* @throws IOException potentially thrown from
response.sendError()
* @throws IOException potentially thrown from
{@link HttpServletResponse#sendError}
*/
protected
ModelAndView
handleHttpMessageNotWritable
(
HttpMessageNotWritableException
ex
,
HttpServletRequest
request
,
HttpServletResponse
response
,
@Nullable
Object
handler
)
throws
IOException
{
...
...
@@ -453,12 +454,12 @@ public class DefaultHandlerExceptionResolver extends AbstractHandlerExceptionRes
/**
* Handle the case where an argument annotated with {@code @Valid} such as
* an {@link RequestBody} or {@link RequestPart} argument fails validation.
*
A
n HTTP 400 error is sent back to the client.
*
<p>By default, a
n HTTP 400 error is sent back to the client.
* @param request current HTTP request
* @param response current HTTP response
* @param handler the executed handler
* @return an empty ModelAndView indicating the exception was handled
* @throws IOException potentially thrown from
response.sendError()
* @throws IOException potentially thrown from
{@link HttpServletResponse#sendError}
*/
protected
ModelAndView
handleMethodArgumentNotValidException
(
MethodArgumentNotValidException
ex
,
HttpServletRequest
request
,
HttpServletResponse
response
,
@Nullable
Object
handler
)
throws
IOException
{
...
...
@@ -470,12 +471,12 @@ public class DefaultHandlerExceptionResolver extends AbstractHandlerExceptionRes
/**
* Handle the case where an {@linkplain RequestPart @RequestPart}, a {@link MultipartFile},
* or a {@code javax.servlet.http.Part} argument is required but is missing.
*
A
n HTTP 400 error is sent back to the client.
*
<p>By default, a
n HTTP 400 error is sent back to the client.
* @param request current HTTP request
* @param response current HTTP response
* @param handler the executed handler
* @return an empty ModelAndView indicating the exception was handled
* @throws IOException potentially thrown from
response.sendError()
* @throws IOException potentially thrown from
{@link HttpServletResponse#sendError}
*/
protected
ModelAndView
handleMissingServletRequestPartException
(
MissingServletRequestPartException
ex
,
HttpServletRequest
request
,
HttpServletResponse
response
,
@Nullable
Object
handler
)
throws
IOException
{
...
...
@@ -488,12 +489,12 @@ public class DefaultHandlerExceptionResolver extends AbstractHandlerExceptionRes
* Handle the case where an {@linkplain ModelAttribute @ModelAttribute} method
* argument has binding or validation errors and is not followed by another
* method argument of type {@link BindingResult}.
* By default, an HTTP 400 error is sent back to the client.
*
<p>
By default, an HTTP 400 error is sent back to the client.
* @param request current HTTP request
* @param response current HTTP response
* @param handler the executed handler
* @return an empty ModelAndView indicating the exception was handled
* @throws IOException potentially thrown from
response.sendError()
* @throws IOException potentially thrown from
{@link HttpServletResponse#sendError}
*/
protected
ModelAndView
handleBindException
(
BindException
ex
,
HttpServletRequest
request
,
HttpServletResponse
response
,
@Nullable
Object
handler
)
throws
IOException
{
...
...
@@ -513,7 +514,7 @@ public class DefaultHandlerExceptionResolver extends AbstractHandlerExceptionRes
* @param handler the executed handler, or {@code null} if none chosen
* at the time of the exception (for example, if multipart resolution failed)
* @return an empty ModelAndView indicating the exception was handled
* @throws IOException potentially thrown from
response.sendError()
* @throws IOException potentially thrown from
{@link HttpServletResponse#sendError}
* @since 4.0
*/
protected
ModelAndView
handleNoHandlerFoundException
(
NoHandlerFoundException
ex
,
...
...
@@ -532,7 +533,7 @@ public class DefaultHandlerExceptionResolver extends AbstractHandlerExceptionRes
* @param handler the executed handler, or {@code null} if none chosen
* at the time of the exception (for example, if multipart resolution failed)
* @return an empty ModelAndView indicating the exception was handled
* @throws IOException potentially thrown from
response.sendError()
* @throws IOException potentially thrown from
{@link HttpServletResponse#sendError}
* @since 4.2.8
*/
protected
ModelAndView
handleAsyncRequestTimeoutException
(
AsyncRequestTimeoutException
ex
,
...
...
spring-webmvc/src/main/java/org/springframework/web/servlet/view/AbstractView.java
浏览文件 @
6027cf22
...
...
@@ -497,8 +497,7 @@ public abstract class AbstractView extends WebApplicationObjectSupport implement
}
protected
String
formatViewName
()
{
return
(
getBeanName
()
!=
null
?
"name '"
+
getBeanName
()
+
"'"
:
"["
+
getClass
().
getSimpleName
()
+
"]"
);
return
(
getBeanName
()
!=
null
?
"name '"
+
getBeanName
()
+
"'"
:
"["
+
getClass
().
getSimpleName
()
+
"]"
);
}
}
spring-webmvc/src/main/java/org/springframework/web/servlet/view/xml/MappingJackson2XmlView.java
浏览文件 @
6027cf22
...
...
@@ -42,6 +42,7 @@ import org.springframework.web.servlet.view.json.AbstractJackson2View;
*
* @author Sebastien Deleuze
* @since 4.1
* @see org.springframework.web.servlet.view.json.MappingJackson2JsonView
*/
public
class
MappingJackson2XmlView
extends
AbstractJackson2View
{
...
...
@@ -73,20 +74,12 @@ public class MappingJackson2XmlView extends AbstractJackson2View {
super
(
xmlMapper
,
DEFAULT_CONTENT_TYPE
);
}
/**
* {@inheritDoc}
*/
@Override
public
void
setModelKey
(
String
modelKey
)
{
this
.
modelKey
=
modelKey
;
}
/**
* Filter out undesired attributes from the given model.
* The return value can be either another {@link Map} or a single value object.
* @param model the model, as passed on to {@link #renderMergedOutputModel}
* @return the value to be rendered
*/
@Override
protected
Object
filterModel
(
Map
<
String
,
Object
>
model
)
{
Object
value
=
null
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录