Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
爱吃血肠
spring-framework
提交
4fa4886e
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,体验更适合开发者的 AI 搜索 >>
提交
4fa4886e
编写于
12月 16, 2015
作者:
J
Juergen Hoeller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Consistent trace log messages and general polishing
(cherry picked from commit
56263848
)
上级
46016d09
变更
19
隐藏空白更改
内联
并排
Showing
19 changed file
with
77 addition
and
82 deletion
+77
-82
spring-webmvc/src/main/java/org/springframework/web/servlet/resource/AbstractResourceResolver.java
...mework/web/servlet/resource/AbstractResourceResolver.java
+7
-6
spring-webmvc/src/main/java/org/springframework/web/servlet/resource/AppCacheManifestTransformer.java
...ork/web/servlet/resource/AppCacheManifestTransformer.java
+7
-8
spring-webmvc/src/main/java/org/springframework/web/servlet/resource/CachingResourceResolver.java
...amework/web/servlet/resource/CachingResourceResolver.java
+8
-5
spring-webmvc/src/main/java/org/springframework/web/servlet/resource/CachingResourceTransformer.java
...work/web/servlet/resource/CachingResourceTransformer.java
+5
-3
spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ContentVersionStrategy.java
...ramework/web/servlet/resource/ContentVersionStrategy.java
+3
-4
spring-webmvc/src/main/java/org/springframework/web/servlet/resource/DefaultResourceResolverChain.java
...rk/web/servlet/resource/DefaultResourceResolverChain.java
+3
-3
spring-webmvc/src/main/java/org/springframework/web/servlet/resource/DefaultResourceTransformerChain.java
...web/servlet/resource/DefaultResourceTransformerChain.java
+7
-5
spring-webmvc/src/main/java/org/springframework/web/servlet/resource/DefaultServletHttpRequestHandler.java
...eb/servlet/resource/DefaultServletHttpRequestHandler.java
+2
-2
spring-webmvc/src/main/java/org/springframework/web/servlet/resource/EncodedResource.java
...springframework/web/servlet/resource/EncodedResource.java
+2
-3
spring-webmvc/src/main/java/org/springframework/web/servlet/resource/FixedVersionStrategy.java
...gframework/web/servlet/resource/FixedVersionStrategy.java
+3
-1
spring-webmvc/src/main/java/org/springframework/web/servlet/resource/GzipResourceResolver.java
...gframework/web/servlet/resource/GzipResourceResolver.java
+3
-7
spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceResolver.java
...pringframework/web/servlet/resource/ResourceResolver.java
+3
-6
spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceResolverChain.java
...framework/web/servlet/resource/ResourceResolverChain.java
+1
-4
spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceTransformer.java
...ngframework/web/servlet/resource/ResourceTransformer.java
+2
-4
spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceTransformerChain.java
...mework/web/servlet/resource/ResourceTransformerChain.java
+2
-4
spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceTransformerSupport.java
...work/web/servlet/resource/ResourceTransformerSupport.java
+5
-5
spring-webmvc/src/main/java/org/springframework/web/servlet/resource/TransformedResource.java
...ngframework/web/servlet/resource/TransformedResource.java
+6
-6
spring-webmvc/src/main/java/org/springframework/web/servlet/resource/VersionPathStrategy.java
...ngframework/web/servlet/resource/VersionPathStrategy.java
+2
-1
spring-webmvc/src/main/java/org/springframework/web/servlet/resource/VersionStrategy.java
...springframework/web/servlet/resource/VersionStrategy.java
+6
-5
未找到文件。
spring-webmvc/src/main/java/org/springframework/web/servlet/resource/AbstractResourceResolver.java
浏览文件 @
4fa4886e
/*
* 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");
* you may not use this file except in compliance with the License.
...
...
@@ -41,25 +41,26 @@ public abstract class AbstractResourceResolver implements ResourceResolver {
List
<?
extends
Resource
>
locations
,
ResourceResolverChain
chain
)
{
if
(
logger
.
isTraceEnabled
())
{
logger
.
trace
(
"Resolving resource
: requestPath=
\""
+
requestPath
+
"\""
);
logger
.
trace
(
"Resolving resource
for request path
\""
+
requestPath
+
"\""
);
}
return
resolveResourceInternal
(
request
,
requestPath
,
locations
,
chain
);
}
protected
abstract
Resource
resolveResourceInternal
(
HttpServletRequest
request
,
String
requestPath
,
List
<?
extends
Resource
>
locations
,
ResourceResolverChain
chain
);
@Override
public
String
resolveUrlPath
(
String
resourceUrlPath
,
List
<?
extends
Resource
>
locations
,
ResourceResolverChain
chain
)
{
if
(
logger
.
isTraceEnabled
())
{
logger
.
trace
(
"Resolving public URL for
path=
\""
+
resourceUrlPath
+
"\""
);
logger
.
trace
(
"Resolving public URL for
resource path
\""
+
resourceUrlPath
+
"\""
);
}
return
resolveUrlPathInternal
(
resourceUrlPath
,
locations
,
chain
);
}
protected
abstract
Resource
resolveResourceInternal
(
HttpServletRequest
request
,
String
requestPath
,
List
<?
extends
Resource
>
locations
,
ResourceResolverChain
chain
);
protected
abstract
String
resolveUrlPathInternal
(
String
resourceUrlPath
,
List
<?
extends
Resource
>
locations
,
ResourceResolverChain
chain
);
...
...
spring-webmvc/src/main/java/org/springframework/web/servlet/resource/AppCacheManifestTransformer.java
浏览文件 @
4fa4886e
/*
* 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");
* you may not use this file except in compliance with the License.
...
...
@@ -20,7 +20,7 @@ import java.io.ByteArrayOutputStream;
import
java.io.IOException
;
import
java.io.StringWriter
;
import
java.nio.charset.Charset
;
import
java.util.
Array
s
;
import
java.util.
Collection
s
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Scanner
;
...
...
@@ -97,9 +97,7 @@ public class AppCacheManifestTransformer extends ResourceTransformerSupport {
throws
IOException
{
resource
=
transformerChain
.
transform
(
request
,
resource
);
String
filename
=
resource
.
getFilename
();
if
(!
this
.
fileExtension
.
equals
(
StringUtils
.
getFilenameExtension
(
filename
)))
{
if
(!
this
.
fileExtension
.
equals
(
StringUtils
.
getFilenameExtension
(
resource
.
getFilename
())))
{
return
resource
;
}
...
...
@@ -138,7 +136,7 @@ public class AppCacheManifestTransformer extends ResourceTransformerSupport {
String
hash
=
hashBuilder
.
build
();
contentWriter
.
write
(
"\n"
+
"# Hash: "
+
hash
);
if
(
logger
.
isTraceEnabled
())
{
logger
.
trace
(
"AppCache file: ["
+
resource
.
getFilename
()+
"]
H
ash: ["
+
hash
+
"]"
);
logger
.
trace
(
"AppCache file: ["
+
resource
.
getFilename
()+
"]
h
ash: ["
+
hash
+
"]"
);
}
return
new
TransformedResource
(
resource
,
contentWriter
.
toString
().
getBytes
(
DEFAULT_CHARSET
));
...
...
@@ -170,7 +168,7 @@ public class AppCacheManifestTransformer extends ResourceTransformerSupport {
private
class
CacheSection
implements
SectionTransformer
{
private
final
String
COMMENT_DIRECTIVE
=
"#"
;
private
static
final
String
COMMENT_DIRECTIVE
=
"#"
;
@Override
public
String
transform
(
String
line
,
HashBuilder
builder
,
Resource
resource
,
...
...
@@ -178,7 +176,8 @@ public class AppCacheManifestTransformer extends ResourceTransformerSupport {
if
(
isLink
(
line
)
&&
!
hasScheme
(
line
))
{
ResourceResolverChain
resolverChain
=
transformerChain
.
getResolverChain
();
Resource
appCacheResource
=
resolverChain
.
resolveResource
(
null
,
line
,
Arrays
.
asList
(
resource
));
Resource
appCacheResource
=
resolverChain
.
resolveResource
(
null
,
line
,
Collections
.
singletonList
(
resource
));
String
path
=
resolveUrlPath
(
line
,
request
,
resource
,
transformerChain
);
builder
.
appendResource
(
appCacheResource
);
if
(
logger
.
isTraceEnabled
())
{
...
...
spring-webmvc/src/main/java/org/springframework/web/servlet/resource/CachingResourceResolver.java
浏览文件 @
4fa4886e
...
...
@@ -42,15 +42,17 @@ public class CachingResourceResolver extends AbstractResourceResolver {
private
final
Cache
cache
;
public
CachingResourceResolver
(
CacheManager
cacheManager
,
String
cacheName
)
{
this
(
cacheManager
.
getCache
(
cacheName
));
}
public
CachingResourceResolver
(
Cache
cache
)
{
Assert
.
notNull
(
cache
,
"
'cache'
is required"
);
Assert
.
notNull
(
cache
,
"
Cache
is required"
);
this
.
cache
=
cache
;
}
/**
* Return the configured {@code Cache}.
*/
...
...
@@ -58,6 +60,7 @@ public class CachingResourceResolver extends AbstractResourceResolver {
return
this
.
cache
;
}
@Override
protected
Resource
resolveResourceInternal
(
HttpServletRequest
request
,
String
requestPath
,
List
<?
extends
Resource
>
locations
,
ResourceResolverChain
chain
)
{
...
...
@@ -67,7 +70,7 @@ public class CachingResourceResolver extends AbstractResourceResolver {
if
(
resource
!=
null
)
{
if
(
logger
.
isTraceEnabled
())
{
logger
.
trace
(
"Found match
"
);
logger
.
trace
(
"Found match
: "
+
resource
);
}
return
resource
;
}
...
...
@@ -75,7 +78,7 @@ public class CachingResourceResolver extends AbstractResourceResolver {
resource
=
chain
.
resolveResource
(
request
,
requestPath
,
locations
);
if
(
resource
!=
null
)
{
if
(
logger
.
isTraceEnabled
())
{
logger
.
trace
(
"Putting resolved resource in cache
"
);
logger
.
trace
(
"Putting resolved resource in cache
: "
+
resource
);
}
this
.
cache
.
put
(
key
,
resource
);
}
...
...
@@ -104,7 +107,7 @@ public class CachingResourceResolver extends AbstractResourceResolver {
if
(
resolvedUrlPath
!=
null
)
{
if
(
logger
.
isTraceEnabled
())
{
logger
.
trace
(
"Found match"
);
logger
.
trace
(
"Found match
: \""
+
resolvedUrlPath
+
"\"
"
);
}
return
resolvedUrlPath
;
}
...
...
@@ -112,7 +115,7 @@ public class CachingResourceResolver extends AbstractResourceResolver {
resolvedUrlPath
=
chain
.
resolveUrlPath
(
resourceUrlPath
,
locations
);
if
(
resolvedUrlPath
!=
null
)
{
if
(
logger
.
isTraceEnabled
())
{
logger
.
trace
(
"Putting resolved resource URL path in cache"
);
logger
.
trace
(
"Putting resolved resource URL path in cache
: \""
+
resolvedUrlPath
+
"\"
"
);
}
this
.
cache
.
put
(
key
,
resolvedUrlPath
);
}
...
...
spring-webmvc/src/main/java/org/springframework/web/servlet/resource/CachingResourceTransformer.java
浏览文件 @
4fa4886e
...
...
@@ -42,12 +42,13 @@ public class CachingResourceTransformer implements ResourceTransformer {
private
final
Cache
cache
;
public
CachingResourceTransformer
(
CacheManager
cacheManager
,
String
cacheName
)
{
this
(
cacheManager
.
getCache
(
cacheName
));
}
public
CachingResourceTransformer
(
Cache
cache
)
{
Assert
.
notNull
(
cache
,
"
'cache'
is required"
);
Assert
.
notNull
(
cache
,
"
Cache
is required"
);
this
.
cache
=
cache
;
}
...
...
@@ -59,6 +60,7 @@ public class CachingResourceTransformer implements ResourceTransformer {
return
this
.
cache
;
}
@Override
public
Resource
transform
(
HttpServletRequest
request
,
Resource
resource
,
ResourceTransformerChain
transformerChain
)
throws
IOException
{
...
...
@@ -66,7 +68,7 @@ public class CachingResourceTransformer implements ResourceTransformer {
Resource
transformed
=
this
.
cache
.
get
(
resource
,
Resource
.
class
);
if
(
transformed
!=
null
)
{
if
(
logger
.
isTraceEnabled
())
{
logger
.
trace
(
"Found match
"
);
logger
.
trace
(
"Found match
: "
+
transformed
);
}
return
transformed
;
}
...
...
@@ -74,7 +76,7 @@ public class CachingResourceTransformer implements ResourceTransformer {
transformed
=
transformerChain
.
transform
(
request
,
resource
);
if
(
logger
.
isTraceEnabled
())
{
logger
.
trace
(
"Putting transformed resource in cache
"
);
logger
.
trace
(
"Putting transformed resource in cache
: "
+
transformed
);
}
this
.
cache
.
put
(
resource
,
transformed
);
...
...
spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ContentVersionStrategy.java
浏览文件 @
4fa4886e
/*
* 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");
* you may not use this file except in compliance with the License.
...
...
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.springframework.web.servlet.resource
;
import
java.io.IOException
;
...
...
@@ -33,12 +34,10 @@ import org.springframework.util.FileCopyUtils;
*/
public
class
ContentVersionStrategy
extends
AbstractVersionStrategy
{
public
ContentVersionStrategy
()
{
super
(
new
FileNameVersionPathStrategy
());
}
@Override
public
String
getResourceVersion
(
Resource
resource
)
{
try
{
...
...
@@ -46,7 +45,7 @@ public class ContentVersionStrategy extends AbstractVersionStrategy {
return
DigestUtils
.
md5DigestAsHex
(
content
);
}
catch
(
IOException
ex
)
{
throw
new
IllegalStateException
(
"Failed to calculate hash for
resource ["
+
resource
+
"]"
,
ex
);
throw
new
IllegalStateException
(
"Failed to calculate hash for
"
+
resource
,
ex
);
}
}
...
...
spring-webmvc/src/main/java/org/springframework/web/servlet/resource/DefaultResourceResolverChain.java
浏览文件 @
4fa4886e
/*
* 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");
* you may not use this file except in compliance with the License.
...
...
@@ -23,7 +23,6 @@ import javax.servlet.http.HttpServletRequest;
import
org.springframework.core.io.Resource
;
import
org.springframework.util.Assert
;
/**
* A default implementation of {@link ResourceResolverChain} for invoking a list
* of {@link ResourceResolver}s.
...
...
@@ -53,6 +52,7 @@ class DefaultResourceResolverChain implements ResourceResolverChain {
if
(
resolver
==
null
)
{
return
null
;
}
try
{
return
resolver
.
resolveResource
(
request
,
requestPath
,
locations
,
this
);
}
...
...
@@ -67,6 +67,7 @@ class DefaultResourceResolverChain implements ResourceResolverChain {
if
(
resolver
==
null
)
{
return
null
;
}
try
{
return
resolver
.
resolveUrlPath
(
resourcePath
,
locations
,
this
);
}
...
...
@@ -76,7 +77,6 @@ class DefaultResourceResolverChain implements ResourceResolverChain {
}
private
ResourceResolver
getNext
()
{
Assert
.
state
(
this
.
index
<=
this
.
resolvers
.
size
(),
"Current index exceeds the number of configured ResourceResolver's"
);
...
...
spring-webmvc/src/main/java/org/springframework/web/servlet/resource/DefaultResourceTransformerChain.java
浏览文件 @
4fa4886e
/*
* 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");
* you may not use this file except in compliance with the License.
...
...
@@ -25,8 +25,8 @@ import org.springframework.core.io.Resource;
import
org.springframework.util.Assert
;
/**
* A default implementation of {@link ResourceTransformerChain} for invoking
a list
* of {@link ResourceTransformer}s.
* A default implementation of {@link ResourceTransformerChain} for invoking
*
a list
of {@link ResourceTransformer}s.
*
* @author Rossen Stoyanchev
* @since 4.1
...
...
@@ -39,10 +39,11 @@ class DefaultResourceTransformerChain implements ResourceTransformerChain {
private
int
index
=
-
1
;
public
DefaultResourceTransformerChain
(
ResourceResolverChain
resolverChain
,
List
<
ResourceTransformer
>
transformers
)
{
Assert
.
notNull
(
resolverChain
,
"
'resolverChain'
is required"
);
Assert
.
notNull
(
resolverChain
,
"
ResourceResolverChain
is required"
);
this
.
resolverChain
=
resolverChain
;
if
(
transformers
!=
null
)
{
this
.
transformers
.
addAll
(
transformers
);
...
...
@@ -54,12 +55,14 @@ class DefaultResourceTransformerChain implements ResourceTransformerChain {
return
this
.
resolverChain
;
}
@Override
public
Resource
transform
(
HttpServletRequest
request
,
Resource
resource
)
throws
IOException
{
ResourceTransformer
transformer
=
getNext
();
if
(
transformer
==
null
)
{
return
resource
;
}
try
{
return
transformer
.
transform
(
request
,
resource
,
this
);
}
...
...
@@ -69,7 +72,6 @@ class DefaultResourceTransformerChain implements ResourceTransformerChain {
}
private
ResourceTransformer
getNext
()
{
Assert
.
state
(
this
.
index
<=
this
.
transformers
.
size
(),
"Current index exceeds the number of configured ResourceTransformer's"
);
...
...
spring-webmvc/src/main/java/org/springframework/web/servlet/resource/DefaultServletHttpRequestHandler.java
浏览文件 @
4fa4886e
/*
* 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");
* you may not use this file except in compliance with the License.
...
...
@@ -117,7 +117,7 @@ public class DefaultServletHttpRequestHandler implements HttpRequestHandler, Ser
RequestDispatcher
rd
=
this
.
servletContext
.
getNamedDispatcher
(
this
.
defaultServletName
);
if
(
rd
==
null
)
{
throw
new
IllegalStateException
(
"A RequestDispatcher could not be located for the default servlet '"
+
this
.
defaultServletName
+
"'"
);
this
.
defaultServletName
+
"'"
);
}
rd
.
forward
(
request
,
response
);
}
...
...
spring-webmvc/src/main/java/org/springframework/web/servlet/resource/EncodedResource.java
浏览文件 @
4fa4886e
/*
* 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");
* you may not use this file except in compliance with the License.
...
...
@@ -18,7 +18,6 @@ package org.springframework.web.servlet.resource;
import
org.springframework.core.io.Resource
;
/**
* Interface for a resource descriptor that describes the encoding
* applied to the entire resource content.
...
...
@@ -39,6 +38,6 @@ public interface EncodedResource extends Resource {
* @see <a href="http://tools.ietf.org/html/rfc7231#section-3.1.2.1">HTTP/1.1: Semantics
* and Content, section 3.1.2.1</a>
*/
public
String
getContentEncoding
();
String
getContentEncoding
();
}
spring-webmvc/src/main/java/org/springframework/web/servlet/resource/FixedVersionStrategy.java
浏览文件 @
4fa4886e
/*
* 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");
* you may not use this file except in compliance with the License.
...
...
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.springframework.web.servlet.resource
;
import
org.springframework.core.io.Resource
;
...
...
@@ -34,6 +35,7 @@ public class FixedVersionStrategy extends AbstractVersionStrategy {
private
final
String
version
;
/**
* Create a new FixedVersionStrategy with the given version string.
* @param version the fixed version string to use
...
...
spring-webmvc/src/main/java/org/springframework/web/servlet/resource/GzipResourceResolver.java
浏览文件 @
4fa4886e
...
...
@@ -27,7 +27,6 @@ import javax.servlet.http.HttpServletRequest;
import
org.springframework.core.io.AbstractResource
;
import
org.springframework.core.io.Resource
;
/**
* A {@code ResourceResolver} that delegates to the chain to locate a resource
* and then attempts to find a variation with the ".gz" extension.
...
...
@@ -42,7 +41,6 @@ import org.springframework.core.io.Resource;
*/
public
class
GzipResourceResolver
extends
AbstractResourceResolver
{
@Override
protected
Resource
resolveResourceInternal
(
HttpServletRequest
request
,
String
requestPath
,
List
<?
extends
Resource
>
locations
,
ResourceResolverChain
chain
)
{
...
...
@@ -58,8 +56,8 @@ public class GzipResourceResolver extends AbstractResourceResolver {
return
gzipped
;
}
}
catch
(
IOException
e
)
{
logger
.
trace
(
"No gzipped resource for ["
+
resource
.
getFilename
()
+
"]"
,
e
);
catch
(
IOException
e
x
)
{
logger
.
trace
(
"No gzipped resource for ["
+
resource
.
getFilename
()
+
"]"
,
e
x
);
}
return
resource
;
...
...
@@ -67,7 +65,7 @@ public class GzipResourceResolver extends AbstractResourceResolver {
private
boolean
isGzipAccepted
(
HttpServletRequest
request
)
{
String
value
=
request
.
getHeader
(
"Accept-Encoding"
);
return
(
(
value
!=
null
)
&&
value
.
toLowerCase
().
contains
(
"gzip"
));
return
(
value
!=
null
&&
value
.
toLowerCase
().
contains
(
"gzip"
));
}
@Override
...
...
@@ -84,13 +82,11 @@ public class GzipResourceResolver extends AbstractResourceResolver {
private
final
Resource
gzipped
;
public
GzippedResource
(
Resource
original
)
throws
IOException
{
this
.
original
=
original
;
this
.
gzipped
=
original
.
createRelative
(
original
.
getFilename
()
+
".gz"
);
}
public
InputStream
getInputStream
()
throws
IOException
{
return
this
.
gzipped
.
getInputStream
();
}
...
...
spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceResolver.java
浏览文件 @
4fa4886e
/*
* 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");
* you may not use this file except in compliance with the License.
...
...
@@ -25,8 +25,8 @@ import org.springframework.core.io.Resource;
* A strategy for resolving a request to a server-side resource.
*
* <p>Provides mechanisms for resolving an incoming request to an actual
* {@link org.springframework.core.io.Resource} and for obtaining the
public
* URL path that clients should use when requesting the resource.
* {@link org.springframework.core.io.Resource} and for obtaining the
*
public
URL path that clients should use when requesting the resource.
*
* @author Jeremy Grelle
* @author Rossen Stoyanchev
...
...
@@ -39,7 +39,6 @@ public interface ResourceResolver {
/**
* Resolve the supplied request and request path to a {@link Resource} that
* exists under one of the given resource locations.
*
* @param request the current request
* @param requestPath the portion of the request path to use
* @param locations the locations to search in when looking up resources
...
...
@@ -53,9 +52,7 @@ public interface ResourceResolver {
* Resolve the externally facing <em>public</em> URL path for clients to use
* to access the resource that is located at the given <em>internal</em>
* resource path.
*
* <p>This is useful when rendering URL links to clients.
*
* @param resourcePath the internal resource path
* @param locations the locations to search in when looking up resources
* @param chain the chain of resolvers to delegate to
...
...
spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceResolverChain.java
浏览文件 @
4fa4886e
/*
* 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");
* you may not use this file except in compliance with the License.
...
...
@@ -35,7 +35,6 @@ public interface ResourceResolverChain {
/**
* Resolve the supplied request and request path to a {@link Resource} that
* exists under one of the given resource locations.
*
* @param request the current request
* @param requestPath the portion of the request path to use
* @param locations the locations to search in when looking up resources
...
...
@@ -47,9 +46,7 @@ public interface ResourceResolverChain {
* Resolve the externally facing <em>public</em> URL path for clients to use
* to access the resource that is located at the given <em>internal</em>
* resource path.
*
* <p>This is useful when rendering URL links to clients.
*
* @param resourcePath the internal resource path
* @param locations the locations to search in when looking up resources
* @return the resolved public URL path or {@code null} if unresolved
...
...
spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceTransformer.java
浏览文件 @
4fa4886e
/*
* 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");
* you may not use this file except in compliance with the License.
...
...
@@ -13,8 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.springframework.web.servlet.resource
;
package
org.springframework.web.servlet.resource
;
import
java.io.IOException
;
import
javax.servlet.http.HttpServletRequest
;
...
...
@@ -32,12 +32,10 @@ public interface ResourceTransformer {
/**
* Transform the given resource.
*
* @param request the current request
* @param resource the resource to transform
* @param transformerChain the chain of remaining transformers to delegate to
* @return the transformed resource, never {@code null}
*
* @throws IOException if the transformation fails
*/
Resource
transform
(
HttpServletRequest
request
,
Resource
resource
,
ResourceTransformerChain
transformerChain
)
...
...
spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceTransformerChain.java
浏览文件 @
4fa4886e
/*
* 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");
* you may not use this file except in compliance with the License.
...
...
@@ -39,12 +39,10 @@ public interface ResourceTransformerChain {
/**
* Transform the given resource.
*
* @param request the current request
* @param resource the candidate resource to transform
* @return the transformed or the same resource, never {@code null}
*
* @throws java.io.IOException if transformation fails
* @throws IOException if transformation fails
*/
Resource
transform
(
HttpServletRequest
request
,
Resource
resource
)
throws
IOException
;
...
...
spring-webmvc/src/main/java/org/springframework/web/servlet/resource/ResourceTransformerSupport.java
浏览文件 @
4fa4886e
/*
* 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");
* you may not use this file except in compliance with the License.
...
...
@@ -13,9 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.springframework.web.servlet.resource
;
import
java.util.
Array
s
;
import
java.util.
Collection
s
;
import
javax.servlet.http.HttpServletRequest
;
import
org.springframework.core.io.Resource
;
...
...
@@ -38,7 +39,6 @@ public abstract class ResourceTransformerSupport implements ResourceTransformer
* URL of links in a transformed resource (e.g. import links in a CSS file).
* This is required only for links expressed as full paths, i.e. including
* context and servlet path, and not for relative links.
*
* <p>By default this property is not set. In that case if a
* {@code ResourceUrlProvider} is needed an attempt is made to find the
* {@code ResourceUrlProvider} exposed through the
...
...
@@ -65,7 +65,6 @@ public abstract class ResourceTransformerSupport implements ResourceTransformer
* contains links to other resources. Such links need to be replaced with the
* public facing link as determined by the resource resolver chain (e.g. the
* public URL may have a version inserted).
*
* @param resourcePath the path to a resource that needs to be re-written
* @param request the current request
* @param resource the resource being transformed
...
...
@@ -82,7 +81,8 @@ public abstract class ResourceTransformerSupport implements ResourceTransformer
}
else
{
// try resolving as relative path
return
transformerChain
.
getResolverChain
().
resolveUrlPath
(
resourcePath
,
Arrays
.
asList
(
resource
));
return
transformerChain
.
getResolverChain
().
resolveUrlPath
(
resourcePath
,
Collections
.
singletonList
(
resource
));
}
}
...
...
spring-webmvc/src/main/java/org/springframework/web/servlet/resource/TransformedResource.java
浏览文件 @
4fa4886e
/*
* 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");
* you may not use this file except in compliance with the License.
...
...
@@ -22,9 +22,9 @@ import org.springframework.core.io.ByteArrayResource;
import
org.springframework.core.io.Resource
;
/**
* An extension of {@link org.springframework.core.io.ByteArrayResource}
that a
*
{@link ResourceTransformer} can use to represent an original resource
* preserving all other information except the content.
* An extension of {@link org.springframework.core.io.ByteArrayResource}
*
that a {@link ResourceTransformer} can use to represent an original
*
resource
preserving all other information except the content.
*
* @author Jeremy Grelle
* @author Rossen Stoyanchev
...
...
@@ -43,9 +43,9 @@ public class TransformedResource extends ByteArrayResource {
try
{
this
.
lastModified
=
original
.
lastModified
();
}
catch
(
IOException
e
)
{
catch
(
IOException
e
x
)
{
// should never happen
throw
new
IllegalArgumentException
(
e
);
throw
new
IllegalArgumentException
(
e
x
);
}
}
...
...
spring-webmvc/src/main/java/org/springframework/web/servlet/resource/VersionPathStrategy.java
浏览文件 @
4fa4886e
/*
* 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");
* you may not use this file except in compliance with the License.
...
...
@@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.springframework.web.servlet.resource
;
/**
...
...
spring-webmvc/src/main/java/org/springframework/web/servlet/resource/VersionStrategy.java
浏览文件 @
4fa4886e
/*
* 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");
* you may not use this file except in compliance with the License.
...
...
@@ -13,13 +13,14 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.springframework.web.servlet.resource
;
import
org.springframework.core.io.Resource
;
/**
* An extension of {@link VersionPathStrategy} that adds a method
to determine the
*
actual version of a {@link org.springframework.core.io.Resource
Resource}.
* An extension of {@link VersionPathStrategy} that adds a method
*
to determine the actual version of a {@link
Resource}.
*
* @author Brian Clozel
* @author Rossen Stoyanchev
...
...
@@ -29,9 +30,9 @@ import org.springframework.core.io.Resource;
public
interface
VersionStrategy
extends
VersionPathStrategy
{
/**
*
Get
the version for the given resource.
*
Determine
the version for the given resource.
* @param resource the resource to check
* @return the version
, never {@code null}
* @return the version
(never {@code null})
*/
String
getResourceVersion
(
Resource
resource
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录