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
6009f417
Commit
6009f417
authored
Oct 09, 2014
by
Phillip Webb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Polish
parent
7e842aee
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
28 deletions
+43
-28
ErrorMvcAutoConfiguration.java
...ork/boot/autoconfigure/web/ErrorMvcAutoConfiguration.java
+29
-17
LoggingApplicationListener.java
...ingframework/boot/logging/LoggingApplicationListener.java
+14
-11
No files found.
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/ErrorMvcAutoConfiguration.java
View file @
6009f417
...
@@ -52,7 +52,6 @@ import org.springframework.expression.spel.standard.SpelExpressionParser;
...
@@ -52,7 +52,6 @@ import org.springframework.expression.spel.standard.SpelExpressionParser;
import
org.springframework.expression.spel.support.StandardEvaluationContext
;
import
org.springframework.expression.spel.support.StandardEvaluationContext
;
import
org.springframework.util.PropertyPlaceholderHelper
;
import
org.springframework.util.PropertyPlaceholderHelper
;
import
org.springframework.util.PropertyPlaceholderHelper.PlaceholderResolver
;
import
org.springframework.util.PropertyPlaceholderHelper.PlaceholderResolver
;
import
org.springframework.web.bind.ServletRequestUtils
;
import
org.springframework.web.servlet.DispatcherServlet
;
import
org.springframework.web.servlet.DispatcherServlet
;
import
org.springframework.web.servlet.View
;
import
org.springframework.web.servlet.View
;
import
org.springframework.web.servlet.view.BeanNameViewResolver
;
import
org.springframework.web.servlet.view.BeanNameViewResolver
;
...
@@ -107,7 +106,7 @@ public class ErrorMvcAutoConfiguration implements EmbeddedServletContainerCustom
...
@@ -107,7 +106,7 @@ public class ErrorMvcAutoConfiguration implements EmbeddedServletContainerCustom
+
"<p>This application has no explicit mapping for /error, so you are seeing this as a fallback.</p>"
+
"<p>This application has no explicit mapping for /error, so you are seeing this as a fallback.</p>"
+
"<div id='created'>${timestamp}</div>"
+
"<div id='created'>${timestamp}</div>"
+
"<div>There was an unexpected error (type=${error}, status=${status}).</div>"
+
"<div>There was an unexpected error (type=${error}, status=${status}).</div>"
+
"<div>${message}</div>
"
+
"
</body></html>"
);
+
"<div>${message}</div></body></html>"
);
@Bean
(
name
=
"error"
)
@Bean
(
name
=
"error"
)
@ConditionalOnMissingBean
(
name
=
"error"
)
@ConditionalOnMissingBean
(
name
=
"error"
)
...
@@ -157,8 +156,6 @@ public class ErrorMvcAutoConfiguration implements EmbeddedServletContainerCustom
...
@@ -157,8 +156,6 @@ public class ErrorMvcAutoConfiguration implements EmbeddedServletContainerCustom
private
final
String
template
;
private
final
String
template
;
private
final
SpelExpressionParser
parser
=
new
SpelExpressionParser
();
private
final
StandardEvaluationContext
context
=
new
StandardEvaluationContext
();
private
final
StandardEvaluationContext
context
=
new
StandardEvaluationContext
();
private
PropertyPlaceholderHelper
helper
;
private
PropertyPlaceholderHelper
helper
;
...
@@ -169,19 +166,7 @@ public class ErrorMvcAutoConfiguration implements EmbeddedServletContainerCustom
...
@@ -169,19 +166,7 @@ public class ErrorMvcAutoConfiguration implements EmbeddedServletContainerCustom
this
.
template
=
template
;
this
.
template
=
template
;
this
.
context
.
addPropertyAccessor
(
new
MapAccessor
());
this
.
context
.
addPropertyAccessor
(
new
MapAccessor
());
this
.
helper
=
new
PropertyPlaceholderHelper
(
"${"
,
"}"
);
this
.
helper
=
new
PropertyPlaceholderHelper
(
"${"
,
"}"
);
this
.
resolver
=
new
PlaceholderResolver
()
{
this
.
resolver
=
new
SpelPlaceholderResolver
(
this
.
context
);
@Override
public
String
resolvePlaceholder
(
String
name
)
{
Expression
expression
=
SpelView
.
this
.
parser
.
parseExpression
(
name
);
try
{
Object
value
=
expression
.
getValue
(
SpelView
.
this
.
context
);
return
(
value
==
null
?
null
:
HtmlUtils
.
htmlEscape
(
value
.
toString
()));
}
catch
(
Exception
ex
)
{
return
null
;
}
}
};
}
}
@Override
@Override
...
@@ -204,4 +189,31 @@ public class ErrorMvcAutoConfiguration implements EmbeddedServletContainerCustom
...
@@ -204,4 +189,31 @@ public class ErrorMvcAutoConfiguration implements EmbeddedServletContainerCustom
}
}
/**
* SpEL based {@link PlaceholderResolver}.
*/
private
static
class
SpelPlaceholderResolver
implements
PlaceholderResolver
{
private
final
SpelExpressionParser
parser
=
new
SpelExpressionParser
();
private
final
StandardEvaluationContext
context
;
public
SpelPlaceholderResolver
(
StandardEvaluationContext
context
)
{
this
.
context
=
context
;
}
@Override
public
String
resolvePlaceholder
(
String
name
)
{
Expression
expression
=
this
.
parser
.
parseExpression
(
name
);
try
{
Object
value
=
expression
.
getValue
(
this
.
context
);
return
HtmlUtils
.
htmlEscape
(
value
==
null
?
null
:
value
.
toString
());
}
catch
(
Exception
ex
)
{
return
null
;
}
}
}
}
}
spring-boot/src/main/java/org/springframework/boot/logging/LoggingApplicationListener.java
View file @
6009f417
...
@@ -222,18 +222,21 @@ public class LoggingApplicationListener implements SmartApplicationListener {
...
@@ -222,18 +222,21 @@ public class LoggingApplicationListener implements SmartApplicationListener {
Map
<
String
,
Object
>
levels
=
new
RelaxedPropertyResolver
(
environment
)
Map
<
String
,
Object
>
levels
=
new
RelaxedPropertyResolver
(
environment
)
.
getSubProperties
(
"logging.level."
);
.
getSubProperties
(
"logging.level."
);
for
(
Entry
<
String
,
Object
>
entry
:
levels
.
entrySet
())
{
for
(
Entry
<
String
,
Object
>
entry
:
levels
.
entrySet
())
{
String
name
=
entry
.
getKey
();
setLogLevel
(
system
,
environment
,
entry
.
getKey
(),
entry
.
getValue
().
toString
());
try
{
}
LogLevel
level
=
LogLevel
.
valueOf
(
environment
.
resolvePlaceholders
(
entry
.
getValue
().
toString
()));
}
if
(
name
.
equalsIgnoreCase
(
"root"
))
{
name
=
null
;
private
void
setLogLevel
(
LoggingSystem
system
,
Environment
environment
,
String
name
,
}
String
level
)
{
system
.
setLogLevel
(
name
,
level
);
try
{
}
if
(
name
.
equalsIgnoreCase
(
"root"
))
{
catch
(
RuntimeException
e
)
{
name
=
null
;
this
.
logger
.
error
(
"Cannot set level: "
+
entry
.
getValue
()
+
" for '"
+
name
+
"'"
);
}
}
level
=
environment
.
resolvePlaceholders
(
level
);
system
.
setLogLevel
(
name
,
LogLevel
.
valueOf
(
level
));
}
catch
(
RuntimeException
ex
)
{
this
.
logger
.
error
(
"Cannot set level: "
+
level
+
" for '"
+
name
+
"'"
);
}
}
}
}
...
...
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