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
dd748eda
Commit
dd748eda
authored
Mar 26, 2015
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use the configured charset, if any, in MustacheViewResolver
Closes gh-2670
parent
2cf23e08
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
1 deletion
+14
-1
MustacheAutoConfiguration.java
...oot/autoconfigure/mustache/MustacheAutoConfiguration.java
+1
-0
MustacheViewResolver.java
...boot/autoconfigure/mustache/web/MustacheViewResolver.java
+13
-1
No files found.
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mustache/MustacheAutoConfiguration.java
View file @
dd748eda
...
...
@@ -108,6 +108,7 @@ public class MustacheAutoConfiguration {
resolver
.
setCache
(
this
.
mustache
.
isCache
());
resolver
.
setViewNames
(
this
.
mustache
.
getViewNames
());
resolver
.
setContentType
(
this
.
mustache
.
getContentType
());
resolver
.
setCharset
(
this
.
mustache
.
getCharset
());
resolver
.
setCompiler
(
mustacheCompiler
);
resolver
.
setOrder
(
Ordered
.
LOWEST_PRECEDENCE
-
10
);
return
resolver
;
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mustache/web/MustacheViewResolver.java
View file @
dd748eda
...
...
@@ -34,12 +34,15 @@ import com.samskivert.mustache.Template;
* Spring MVC {@link ViewResolver} for Mustache.
*
* @author Dave Syer
* @author Andy Wilkinson
* @since 1.2.2
*/
public
class
MustacheViewResolver
extends
UrlBasedViewResolver
{
private
Compiler
compiler
=
Mustache
.
compiler
();
private
String
charset
;
public
MustacheViewResolver
()
{
setViewClass
(
MustacheView
.
class
);
}
...
...
@@ -51,6 +54,13 @@ public class MustacheViewResolver extends UrlBasedViewResolver {
this
.
compiler
=
compiler
;
}
/**
* @param charset the charset to set
*/
public
void
setCharset
(
String
charset
)
{
this
.
charset
=
charset
;
}
@Override
protected
View
loadView
(
String
viewName
,
Locale
locale
)
throws
Exception
{
Resource
resource
=
resolveResource
(
viewName
,
locale
);
...
...
@@ -64,7 +74,9 @@ public class MustacheViewResolver extends UrlBasedViewResolver {
}
private
Template
createTemplate
(
Resource
resource
)
throws
IOException
{
return
this
.
compiler
.
compile
(
new
InputStreamReader
(
resource
.
getInputStream
()));
return
this
.
charset
==
null
?
this
.
compiler
.
compile
(
new
InputStreamReader
(
resource
.
getInputStream
()))
:
this
.
compiler
.
compile
(
new
InputStreamReader
(
resource
.
getInputStream
(),
this
.
charset
));
}
private
Resource
resolveResource
(
String
viewName
,
Locale
locale
)
{
...
...
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