Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
36542549
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,发现更多精彩内容 >>
提交
36542549
编写于
8月 29, 2014
作者:
S
Sebastien Deleuze
提交者:
Rossen Stoyanchev
8月 29, 2014
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add HTTP status to ServletRequestHandledEvent
Issue: SPR-12119
上级
5857cef0
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
44 addition
and
5 deletion
+44
-5
spring-web/src/main/java/org/springframework/web/context/support/ServletRequestHandledEvent.java
...ework/web/context/support/ServletRequestHandledEvent.java
+41
-2
spring-webmvc/src/main/java/org/springframework/web/servlet/FrameworkServlet.java
...ava/org/springframework/web/servlet/FrameworkServlet.java
+3
-3
未找到文件。
spring-web/src/main/java/org/springframework/web/context/support/ServletRequestHandledEvent.java
浏览文件 @
36542549
/*
/*
* Copyright 2002-201
2
the original author or authors.
* Copyright 2002-201
4
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.
...
@@ -28,7 +28,7 @@ package org.springframework.web.context.support;
...
@@ -28,7 +28,7 @@ package org.springframework.web.context.support;
@SuppressWarnings
(
"serial"
)
@SuppressWarnings
(
"serial"
)
public
class
ServletRequestHandledEvent
extends
RequestHandledEvent
{
public
class
ServletRequestHandledEvent
extends
RequestHandledEvent
{
/** URL that t
he t
riggered the request */
/** URL that triggered the request */
private
final
String
requestUrl
;
private
final
String
requestUrl
;
/** IP address that the request came from */
/** IP address that the request came from */
...
@@ -40,6 +40,9 @@ public class ServletRequestHandledEvent extends RequestHandledEvent {
...
@@ -40,6 +40,9 @@ public class ServletRequestHandledEvent extends RequestHandledEvent {
/** Name of the servlet that handled the request */
/** Name of the servlet that handled the request */
private
final
String
servletName
;
private
final
String
servletName
;
/** HTTP status code of the response */
private
final
int
statusCode
;
/**
/**
* Create a new ServletRequestHandledEvent.
* Create a new ServletRequestHandledEvent.
...
@@ -62,6 +65,7 @@ public class ServletRequestHandledEvent extends RequestHandledEvent {
...
@@ -62,6 +65,7 @@ public class ServletRequestHandledEvent extends RequestHandledEvent {
this
.
clientAddress
=
clientAddress
;
this
.
clientAddress
=
clientAddress
;
this
.
method
=
method
;
this
.
method
=
method
;
this
.
servletName
=
servletName
;
this
.
servletName
=
servletName
;
this
.
statusCode
=
-
1
;
}
}
/**
/**
...
@@ -86,6 +90,33 @@ public class ServletRequestHandledEvent extends RequestHandledEvent {
...
@@ -86,6 +90,33 @@ public class ServletRequestHandledEvent extends RequestHandledEvent {
this
.
clientAddress
=
clientAddress
;
this
.
clientAddress
=
clientAddress
;
this
.
method
=
method
;
this
.
method
=
method
;
this
.
servletName
=
servletName
;
this
.
servletName
=
servletName
;
this
.
statusCode
=
-
1
;
}
/**
* Create a new ServletRequestHandledEvent.
* @param source the component that published the event
* @param requestUrl the URL of the request
* @param clientAddress the IP address that the request came from
* @param method the HTTP method of the request (usually GET or POST)
* @param servletName the name of the servlet that handled the request
* @param sessionId the id of the HTTP session, if any
* @param userName the name of the user that was associated with the
* request, if any (usually the UserPrincipal)
* @param processingTimeMillis the processing time of the request in milliseconds
* @param failureCause the cause of failure, if any
* @param statusCode the HTTP status code of the response
*/
public
ServletRequestHandledEvent
(
Object
source
,
String
requestUrl
,
String
clientAddress
,
String
method
,
String
servletName
,
String
sessionId
,
String
userName
,
long
processingTimeMillis
,
Throwable
failureCause
,
int
statusCode
)
{
super
(
source
,
sessionId
,
userName
,
processingTimeMillis
,
failureCause
);
this
.
requestUrl
=
requestUrl
;
this
.
clientAddress
=
clientAddress
;
this
.
method
=
method
;
this
.
servletName
=
servletName
;
this
.
statusCode
=
statusCode
;
}
}
...
@@ -117,6 +148,14 @@ public class ServletRequestHandledEvent extends RequestHandledEvent {
...
@@ -117,6 +148,14 @@ public class ServletRequestHandledEvent extends RequestHandledEvent {
return
this
.
servletName
;
return
this
.
servletName
;
}
}
/**
* Return the HTTP status code of the response or -1 if the status
* code is not available.
* @since 4.1
*/
public
int
getStatusCode
()
{
return
this
.
statusCode
;
}
@Override
@Override
public
String
getShortDescription
()
{
public
String
getShortDescription
()
{
...
...
spring-webmvc/src/main/java/org/springframework/web/servlet/FrameworkServlet.java
浏览文件 @
36542549
...
@@ -993,7 +993,7 @@ public abstract class FrameworkServlet extends HttpServletBean implements Applic
...
@@ -993,7 +993,7 @@ public abstract class FrameworkServlet extends HttpServletBean implements Applic
}
}
}
}
publishRequestHandledEvent
(
request
,
startTime
,
failureCause
);
publishRequestHandledEvent
(
request
,
response
,
startTime
,
failureCause
);
}
}
}
}
...
@@ -1054,7 +1054,7 @@ public abstract class FrameworkServlet extends HttpServletBean implements Applic
...
@@ -1054,7 +1054,7 @@ public abstract class FrameworkServlet extends HttpServletBean implements Applic
}
}
}
}
private
void
publishRequestHandledEvent
(
HttpServletRequest
request
,
long
startTime
,
Throwable
failureCause
)
{
private
void
publishRequestHandledEvent
(
HttpServletRequest
request
,
HttpServletResponse
response
,
long
startTime
,
Throwable
failureCause
)
{
if
(
this
.
publishEvents
)
{
if
(
this
.
publishEvents
)
{
// Whether or not we succeeded, publish an event.
// Whether or not we succeeded, publish an event.
long
processingTime
=
System
.
currentTimeMillis
()
-
startTime
;
long
processingTime
=
System
.
currentTimeMillis
()
-
startTime
;
...
@@ -1063,7 +1063,7 @@ public abstract class FrameworkServlet extends HttpServletBean implements Applic
...
@@ -1063,7 +1063,7 @@ public abstract class FrameworkServlet extends HttpServletBean implements Applic
request
.
getRequestURI
(),
request
.
getRemoteAddr
(),
request
.
getRequestURI
(),
request
.
getRemoteAddr
(),
request
.
getMethod
(),
getServletConfig
().
getServletName
(),
request
.
getMethod
(),
getServletConfig
().
getServletName
(),
WebUtils
.
getSessionId
(
request
),
getUsernameForRequest
(
request
),
WebUtils
.
getSessionId
(
request
),
getUsernameForRequest
(
request
),
processingTime
,
failureCause
));
processingTime
,
failureCause
,
response
.
getStatus
()
));
}
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录