Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
带水的鱼儿
spring-framework
提交
95d7f883
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,发现更多精彩内容 >>
提交
95d7f883
编写于
7月 13, 2021
作者:
R
Rossen Stoyanchev
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Deprecate LastModified
See gh-27075
上级
25131ebf
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
36 addition
and
24 deletion
+36
-24
spring-webmvc/src/main/java/org/springframework/web/servlet/DispatcherServlet.java
...va/org/springframework/web/servlet/DispatcherServlet.java
+1
-0
spring-webmvc/src/main/java/org/springframework/web/servlet/HandlerAdapter.java
.../java/org/springframework/web/servlet/HandlerAdapter.java
+4
-3
spring-webmvc/src/main/java/org/springframework/web/servlet/function/support/HandlerFunctionAdapter.java
.../web/servlet/function/support/HandlerFunctionAdapter.java
+2
-1
spring-webmvc/src/main/java/org/springframework/web/servlet/handler/SimpleServletHandlerAdapter.java
...work/web/servlet/handler/SimpleServletHandlerAdapter.java
+2
-1
spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/Controller.java
.../java/org/springframework/web/servlet/mvc/Controller.java
+4
-3
spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/HttpRequestHandlerAdapter.java
...gframework/web/servlet/mvc/HttpRequestHandlerAdapter.java
+2
-2
spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/LastModified.java
...ava/org/springframework/web/servlet/mvc/LastModified.java
+7
-1
spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/SimpleControllerHandlerAdapter.java
...ework/web/servlet/mvc/SimpleControllerHandlerAdapter.java
+2
-2
spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/AbstractHandlerMethodAdapter.java
.../web/servlet/mvc/method/AbstractHandlerMethodAdapter.java
+5
-1
spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapter.java
...t/mvc/method/annotation/RequestMappingHandlerAdapter.java
+1
-0
spring-webmvc/src/test/java/org/springframework/web/servlet/SimpleWebApplicationContext.java
...ingframework/web/servlet/SimpleWebApplicationContext.java
+3
-3
src/docs/asciidoc/web/webmvc.adoc
src/docs/asciidoc/web/webmvc.adoc
+3
-7
未找到文件。
spring-webmvc/src/main/java/org/springframework/web/servlet/DispatcherServlet.java
浏览文件 @
95d7f883
...
...
@@ -1020,6 +1020,7 @@ public class DispatcherServlet extends FrameworkServlet {
* @param response current HTTP response
* @throws Exception in case of any kind of processing failure
*/
@SuppressWarnings
(
"deprecation"
)
protected
void
doDispatch
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
Exception
{
HttpServletRequest
processedRequest
=
request
;
HandlerExecutionChain
mappedHandler
=
null
;
...
...
spring-webmvc/src/main/java/org/springframework/web/servlet/HandlerAdapter.java
浏览文件 @
95d7f883
/*
* Copyright 2002-20
18
the original author or authors.
* Copyright 2002-20
21
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.
...
...
@@ -83,9 +83,10 @@ public interface HandlerAdapter {
* @param request current HTTP request
* @param handler the handler to use
* @return the lastModified value for the given handler
* @
see javax.servlet.http.HttpServlet#getLastModified
*
@see org.springframework.web.servlet.mvc.LastModified#getLastModified
* @
deprecated as of 5.3.9 along with
*
{@link org.springframework.web.servlet.mvc.LastModified}.
*/
@Deprecated
long
getLastModified
(
HttpServletRequest
request
,
Object
handler
);
}
spring-webmvc/src/main/java/org/springframework/web/servlet/function/support/HandlerFunctionAdapter.java
浏览文件 @
95d7f883
/*
* Copyright 2002-20
19
the original author or authors.
* Copyright 2002-20
21
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.
...
...
@@ -157,6 +157,7 @@ public class HandlerFunctionAdapter implements HandlerAdapter, Ordered {
}
@Override
@SuppressWarnings
(
"deprecation"
)
public
long
getLastModified
(
HttpServletRequest
request
,
Object
handler
)
{
return
-
1L
;
}
...
...
spring-webmvc/src/main/java/org/springframework/web/servlet/handler/SimpleServletHandlerAdapter.java
浏览文件 @
95d7f883
/*
* Copyright 2002-20
12
the original author or authors.
* Copyright 2002-20
21
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.
...
...
@@ -69,6 +69,7 @@ public class SimpleServletHandlerAdapter implements HandlerAdapter {
}
@Override
@SuppressWarnings
(
"deprecation"
)
public
long
getLastModified
(
HttpServletRequest
request
,
Object
handler
)
{
return
-
1
;
}
...
...
spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/Controller.java
浏览文件 @
95d7f883
/*
* Copyright 2002-20
16
the original author or authors.
* Copyright 2002-20
21
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.
...
...
@@ -93,11 +93,12 @@ import org.springframework.web.servlet.ModelAndView;
* you all those references through convenient accessors but requires an
* ApplicationContext reference on initialization.
*
* <p>Controllers can optionally implement the {@link LastModified} interface.
* <p>Controllers can use the {@code checkNotModified} methods on
* {@link org.springframework.web.context.request.WebRequest} for HTTP caching
* support.
*
* @author Rod Johnson
* @author Juergen Hoeller
* @see LastModified
* @see SimpleControllerHandlerAdapter
* @see AbstractController
* @see org.springframework.mock.web.MockHttpServletRequest
...
...
spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/HttpRequestHandlerAdapter.java
浏览文件 @
95d7f883
/*
* Copyright 2002-20
12
the original author or authors.
* Copyright 2002-20
21
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.
...
...
@@ -35,7 +35,6 @@ import org.springframework.web.servlet.ModelAndView;
* @since 2.0
* @see org.springframework.web.servlet.DispatcherServlet
* @see org.springframework.web.HttpRequestHandler
* @see LastModified
* @see SimpleControllerHandlerAdapter
*/
public
class
HttpRequestHandlerAdapter
implements
HandlerAdapter
{
...
...
@@ -55,6 +54,7 @@ public class HttpRequestHandlerAdapter implements HandlerAdapter {
}
@Override
@SuppressWarnings
(
"deprecation"
)
public
long
getLastModified
(
HttpServletRequest
request
,
Object
handler
)
{
if
(
handler
instanceof
LastModified
)
{
return
((
LastModified
)
handler
).
getLastModified
(
request
);
...
...
spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/LastModified.java
浏览文件 @
95d7f883
/*
* Copyright 2002-20
12
the original author or authors.
* Copyright 2002-20
21
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.
...
...
@@ -34,12 +34,18 @@ import javax.servlet.http.HttpServletRequest;
*
* @author Rod Johnson
* @author Juergen Hoeller
* @deprecated as of 5.3.9 in favor of using the {@code checkNotModified} methods
* in {@link org.springframework.web.context.request.WebRequest}, or from an
* annotated controller method, returning a
* {@link org.springframework.http.ResponseEntity} with an "ETag" and/or
* "Last-Modified" headers set.
* @see javax.servlet.http.HttpServlet#getLastModified
* @see Controller
* @see SimpleControllerHandlerAdapter
* @see org.springframework.web.HttpRequestHandler
* @see HttpRequestHandlerAdapter
*/
@Deprecated
public
interface
LastModified
{
/**
...
...
spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/SimpleControllerHandlerAdapter.java
浏览文件 @
95d7f883
/*
* Copyright 2002-20
12
the original author or authors.
* Copyright 2002-20
21
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.
...
...
@@ -34,7 +34,6 @@ import org.springframework.web.servlet.ModelAndView;
* @author Juergen Hoeller
* @see org.springframework.web.servlet.DispatcherServlet
* @see Controller
* @see LastModified
* @see HttpRequestHandlerAdapter
*/
public
class
SimpleControllerHandlerAdapter
implements
HandlerAdapter
{
...
...
@@ -53,6 +52,7 @@ public class SimpleControllerHandlerAdapter implements HandlerAdapter {
}
@Override
@SuppressWarnings
(
"deprecation"
)
public
long
getLastModified
(
HttpServletRequest
request
,
Object
handler
)
{
if
(
handler
instanceof
LastModified
)
{
return
((
LastModified
)
handler
).
getLastModified
(
request
);
...
...
spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/AbstractHandlerMethodAdapter.java
浏览文件 @
95d7f883
/*
* Copyright 2002-20
18
the original author or authors.
* Copyright 2002-20
21
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.
...
...
@@ -105,6 +105,7 @@ public abstract class AbstractHandlerMethodAdapter extends WebContentGenerator i
* This implementation expects the handler to be an {@link HandlerMethod}.
*/
@Override
@SuppressWarnings
(
"deprecation"
)
public
final
long
getLastModified
(
HttpServletRequest
request
,
Object
handler
)
{
return
getLastModifiedInternal
(
request
,
(
HandlerMethod
)
handler
);
}
...
...
@@ -114,7 +115,10 @@ public abstract class AbstractHandlerMethodAdapter extends WebContentGenerator i
* @param request current HTTP request
* @param handlerMethod handler method to use
* @return the lastModified value for the given handler
* @deprecated as of 5.3.9 along with
* {@link org.springframework.web.servlet.mvc.LastModified}.
*/
@Deprecated
protected
abstract
long
getLastModifiedInternal
(
HttpServletRequest
request
,
HandlerMethod
handlerMethod
);
}
spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/annotation/RequestMappingHandlerAdapter.java
浏览文件 @
95d7f883
...
...
@@ -826,6 +826,7 @@ public class RequestMappingHandlerAdapter extends AbstractHandlerMethodAdapter
* and return {@code null} if the result of that call is {@code true}.
*/
@Override
@SuppressWarnings
(
"deprecation"
)
protected
long
getLastModifiedInternal
(
HttpServletRequest
request
,
HandlerMethod
handlerMethod
)
{
return
-
1
;
}
...
...
spring-webmvc/src/test/java/org/springframework/web/servlet/SimpleWebApplicationContext.java
浏览文件 @
95d7f883
/*
* Copyright 2002-20
19
the original author or authors.
* Copyright 2002-20
21
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.
...
...
@@ -34,7 +34,6 @@ import org.springframework.web.context.support.StaticWebApplicationContext;
import
org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping
;
import
org.springframework.web.servlet.i18n.AcceptHeaderLocaleResolver
;
import
org.springframework.web.servlet.mvc.Controller
;
import
org.springframework.web.servlet.mvc.LastModified
;
import
org.springframework.web.servlet.support.RequestContextUtils
;
import
org.springframework.web.servlet.theme.AbstractThemeResolver
;
import
org.springframework.web.servlet.view.InternalResourceViewResolver
;
...
...
@@ -68,7 +67,8 @@ public class SimpleWebApplicationContext extends StaticWebApplicationContext {
}
public
static
class
LocaleChecker
implements
Controller
,
LastModified
{
@SuppressWarnings
(
"deprecation"
)
public
static
class
LocaleChecker
implements
Controller
,
org
.
springframework
.
web
.
servlet
.
mvc
.
LastModified
{
@Override
public
ModelAndView
handleRequest
(
HttpServletRequest
request
,
HttpServletResponse
response
)
...
...
src/docs/asciidoc/web/webmvc.adoc
浏览文件 @
95d7f883
...
...
@@ -527,13 +527,9 @@ The `HandlerExceptionResolver` beans declared in the `WebApplicationContext` are
resolve exceptions thrown during request processing. Those exception resolvers allow
customizing the logic to address exceptions. See <<mvc-exceptionhandlers>> for more details.
The Spring `DispatcherServlet` also supports the return of the
`last-modification-date`, as specified by the Servlet API. The process of determining
the last modification date for a specific request is straightforward: The
`DispatcherServlet` looks up an appropriate handler mapping and tests whether the
handler that is found implements the `LastModified` interface. If so, the value of the
`long getLastModified(request)` method of the `LastModified` interface is returned to
the client.
For HTTP caching support, handlers can use the `checkNotModified` methods of `WebRequest`,
along with further options for annoated controllers as described in
<<mvc-caching-etag-lastmodified,HTTP Caching for Controllers>>.
You can customize individual `DispatcherServlet` instances by adding Servlet
initialization parameters (`init-param` elements) to the Servlet declaration in the
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录