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
4637c2a8
Commit
4637c2a8
authored
Mar 22, 2014
by
Dave Syer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Accept viewNames and excludedViewNames for ThymeleafViewResolver
(via spring.thymeleaf.*). Fixes gh-548
parent
e472e7cc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
0 deletions
+16
-0
ThymeleafAutoConfiguration.java
...t/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java
+4
-0
ThymeleafAutoConfigurationTests.java
...oconfigure/thymeleaf/ThymeleafAutoConfigurationTests.java
+12
-0
No files found.
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfiguration.java
View file @
4637c2a8
...
...
@@ -178,6 +178,10 @@ public class ThymeleafAutoConfiguration {
resolver
.
setTemplateEngine
(
this
.
templateEngine
);
resolver
.
setCharacterEncoding
(
this
.
environment
.
getProperty
(
"encoding"
,
"UTF-8"
));
resolver
.
setExcludedViewNames
(
this
.
environment
.
getProperty
(
"excludedViewNames"
,
String
[].
class
));
resolver
.
setViewNames
(
this
.
environment
.
getProperty
(
"viewNames"
,
String
[].
class
));
// Needs to come before any fallback resolver (e.g. a
// InternalResourceViewResolver)
resolver
.
setOrder
(
Ordered
.
LOWEST_PRECEDENCE
-
20
);
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/thymeleaf/ThymeleafAutoConfigurationTests.java
View file @
4637c2a8
...
...
@@ -38,6 +38,7 @@ import org.thymeleaf.spring4.view.ThymeleafViewResolver;
import
org.thymeleaf.templateresolver.ITemplateResolver
;
import
org.thymeleaf.templateresolver.TemplateResolver
;
import
static
org
.
junit
.
Assert
.
assertArrayEquals
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertTrue
;
...
...
@@ -85,6 +86,17 @@ public class ThymeleafAutoConfigurationTests {
assertEquals
(
"UTF-16"
,
views
.
getCharacterEncoding
());
}
@Test
public
void
overrideViewNames
()
throws
Exception
{
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"spring.thymeleaf.viewNames:foo,bar"
);
this
.
context
.
register
(
ThymeleafAutoConfiguration
.
class
,
PropertyPlaceholderAutoConfiguration
.
class
);
this
.
context
.
refresh
();
ThymeleafViewResolver
views
=
this
.
context
.
getBean
(
ThymeleafViewResolver
.
class
);
assertArrayEquals
(
new
String
[]
{
"foo"
,
"bar"
},
views
.
getViewNames
());
}
@Test
(
expected
=
BeanCreationException
.
class
)
public
void
templateLocationDoesNotExist
()
throws
Exception
{
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
...
...
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