Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
ef39634e
Commit
ef39634e
authored
Jul 08, 2015
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish
parent
7dcb79b3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
61 deletions
+53
-61
ResourceProperties.java
...gframework/boot/autoconfigure/web/ResourceProperties.java
+53
-61
No files found.
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ResourceProperties.java
View file @
ef39634e
...
@@ -54,13 +54,11 @@ public class ResourceProperties implements ResourceLoaderAware {
...
@@ -54,13 +54,11 @@ public class ResourceProperties implements ResourceLoaderAware {
SERVLET_RESOURCE_LOCATIONS
.
length
,
CLASSPATH_RESOURCE_LOCATIONS
.
length
);
SERVLET_RESOURCE_LOCATIONS
.
length
,
CLASSPATH_RESOURCE_LOCATIONS
.
length
);
}
}
private
static
final
String
[]
STATIC_INDEX_HTML_RESOURCES
;
/**
static
{
* Locations of static resources. Defaults to classpath:[/META-INF/resources/,
STATIC_INDEX_HTML_RESOURCES
=
new
String
[
RESOURCE_LOCATIONS
.
length
];
* /resources/, /static/, /public/] plus context:/ (the root of the servlet context).
for
(
int
i
=
0
;
i
<
STATIC_INDEX_HTML_RESOURCES
.
length
;
i
++)
{
*/
STATIC_INDEX_HTML_RESOURCES
[
i
]
=
RESOURCE_LOCATIONS
[
i
]
+
"index.html"
;
private
String
[]
staticLocations
=
RESOURCE_LOCATIONS
;
}
}
/**
/**
* Cache period for the resources served by the resource handler, in seconds.
* Cache period for the resources served by the resource handler, in seconds.
...
@@ -74,12 +72,6 @@ public class ResourceProperties implements ResourceLoaderAware {
...
@@ -74,12 +72,6 @@ public class ResourceProperties implements ResourceLoaderAware {
private
final
Chain
chain
=
new
Chain
();
private
final
Chain
chain
=
new
Chain
();
/**
* Locations of static resources. Defaults to classpath:[/META-INF/resources/,
* /resources/, /static/, /public/] plus context:/ (the root of the servlet context).
*/
private
String
[]
staticLocations
=
RESOURCE_LOCATIONS
;
private
ResourceLoader
resourceLoader
;
private
ResourceLoader
resourceLoader
;
@Override
@Override
...
@@ -87,6 +79,54 @@ public class ResourceProperties implements ResourceLoaderAware {
...
@@ -87,6 +79,54 @@ public class ResourceProperties implements ResourceLoaderAware {
this
.
resourceLoader
=
resourceLoader
;
this
.
resourceLoader
=
resourceLoader
;
}
}
public
String
[]
getStaticLocations
()
{
return
this
.
staticLocations
;
}
public
void
setStaticLocations
(
String
[]
staticLocations
)
{
this
.
staticLocations
=
staticLocations
;
}
public
Resource
getWelcomePage
()
{
for
(
String
location
:
getStaticWelcomePageLocations
())
{
Resource
resource
=
this
.
resourceLoader
.
getResource
(
location
);
if
(
resource
.
exists
())
{
try
{
resource
.
getURL
();
return
resource
;
}
catch
(
IOException
ex
)
{
// Ignore
}
}
}
return
null
;
}
private
String
[]
getStaticWelcomePageLocations
()
{
String
[]
result
=
new
String
[
this
.
staticLocations
.
length
];
for
(
int
i
=
0
;
i
<
result
.
length
;
i
++)
{
String
location
=
this
.
staticLocations
[
i
];
if
(!
location
.
endsWith
(
"/"
))
{
location
=
location
+
"/"
;
}
result
[
i
]
=
location
+
"index.html"
;
}
return
result
;
}
public
List
<
Resource
>
getFaviconLocations
()
{
List
<
Resource
>
locations
=
new
ArrayList
<
Resource
>(
CLASSPATH_RESOURCE_LOCATIONS
.
length
+
1
);
if
(
this
.
resourceLoader
!=
null
)
{
for
(
String
location
:
CLASSPATH_RESOURCE_LOCATIONS
)
{
locations
.
add
(
this
.
resourceLoader
.
getResource
(
location
));
}
}
locations
.
add
(
new
ClassPathResource
(
"/"
));
return
Collections
.
unmodifiableList
(
locations
);
}
public
Integer
getCachePeriod
()
{
public
Integer
getCachePeriod
()
{
return
this
.
cachePeriod
;
return
this
.
cachePeriod
;
}
}
...
@@ -258,52 +298,4 @@ public class ResourceProperties implements ResourceLoaderAware {
...
@@ -258,52 +298,4 @@ public class ResourceProperties implements ResourceLoaderAware {
}
}
public
String
[]
getStaticLocations
()
{
return
this
.
staticLocations
;
}
public
void
setStaticLocations
(
String
[]
staticLocations
)
{
this
.
staticLocations
=
staticLocations
;
}
private
String
[]
getStaticWelcomePageLocations
()
{
String
[]
result
=
new
String
[
this
.
staticLocations
.
length
];
for
(
int
i
=
0
;
i
<
result
.
length
;
i
++)
{
String
location
=
this
.
staticLocations
[
i
];
if
(!
location
.
endsWith
(
"/"
))
{
location
=
location
+
"/"
;
}
result
[
i
]
=
location
+
"index.html"
;
}
return
result
;
}
public
List
<
Resource
>
getFaviconLocations
()
{
List
<
Resource
>
locations
=
new
ArrayList
<
Resource
>(
CLASSPATH_RESOURCE_LOCATIONS
.
length
+
1
);
if
(
this
.
resourceLoader
!=
null
)
{
for
(
String
location
:
CLASSPATH_RESOURCE_LOCATIONS
)
{
locations
.
add
(
this
.
resourceLoader
.
getResource
(
location
));
}
}
locations
.
add
(
new
ClassPathResource
(
"/"
));
return
Collections
.
unmodifiableList
(
locations
);
}
public
Resource
getWelcomePage
()
{
for
(
String
location
:
getStaticWelcomePageLocations
())
{
Resource
resource
=
this
.
resourceLoader
.
getResource
(
location
);
if
(
resource
.
exists
())
{
try
{
resource
.
getURL
();
return
resource
;
}
catch
(
IOException
ex
)
{
// Ignore
}
}
}
return
null
;
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment