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
699d083c
Commit
699d083c
authored
May 10, 2016
by
Stephane Nicoll
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add load-on-startup property to DispatcherServlet
Closes gh-2481
parent
dc353674
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
34 additions
and
5 deletions
+34
-5
DispatcherServletAutoConfiguration.java
...autoconfigure/web/DispatcherServletAutoConfiguration.java
+2
-0
WebMvcProperties.java
...ingframework/boot/autoconfigure/web/WebMvcProperties.java
+23
-0
DispatcherServletAutoConfigurationTests.java
...onfigure/web/DispatcherServletAutoConfigurationTests.java
+8
-5
appendix-application-properties.adoc
...cs/src/main/asciidoc/appendix-application-properties.adoc
+1
-0
No files found.
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/DispatcherServletAutoConfiguration.java
View file @
699d083c
...
...
@@ -110,6 +110,8 @@ public class DispatcherServletAutoConfiguration {
ServletRegistrationBean
registration
=
new
ServletRegistrationBean
(
dispatcherServlet
(),
this
.
server
.
getServletMapping
());
registration
.
setName
(
DEFAULT_DISPATCHER_SERVLET_BEAN_NAME
);
registration
.
setLoadOnStartup
(
this
.
webMvcProperties
.
getServlet
().
getLoadOnStartup
());
if
(
this
.
multipartConfig
!=
null
)
{
registration
.
setMultipartConfig
(
this
.
multipartConfig
);
}
...
...
spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/web/WebMvcProperties.java
View file @
699d083c
...
...
@@ -84,6 +84,8 @@ public class WebMvcProperties {
private
final
Async
async
=
new
Async
();
private
final
Servlet
servlet
=
new
Servlet
();
private
final
View
view
=
new
View
();
public
DefaultMessageCodesResolver
.
Format
getMessageCodesResolverFormat
()
{
...
...
@@ -164,6 +166,10 @@ public class WebMvcProperties {
return
this
.
async
;
}
public
Servlet
getServlet
()
{
return
this
.
servlet
;
}
public
View
getView
()
{
return
this
.
view
;
}
...
...
@@ -187,6 +193,23 @@ public class WebMvcProperties {
}
public
static
class
Servlet
{
/**
* Load on startup priority of the dispatcher servlet.
*/
private
int
loadOnStartup
=
-
1
;
public
int
getLoadOnStartup
()
{
return
this
.
loadOnStartup
;
}
public
void
setLoadOnStartup
(
int
loadOnStartup
)
{
this
.
loadOnStartup
=
loadOnStartup
;
}
}
public
static
class
View
{
/**
...
...
spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/web/DispatcherServletAutoConfigurationTests.java
View file @
699d083c
...
...
@@ -22,6 +22,7 @@ import javax.servlet.http.HttpServletRequest;
import
org.junit.After
;
import
org.junit.Test
;
import
org.springframework.beans.DirectFieldAccessor
;
import
org.springframework.beans.factory.UnsatisfiedDependencyException
;
import
org.springframework.boot.test.util.EnvironmentTestUtils
;
import
org.springframework.boot.web.servlet.MultipartConfigFactory
;
...
...
@@ -151,17 +152,19 @@ public class DispatcherServletAutoConfigurationTests {
this
.
context
.
register
(
ServerPropertiesAutoConfiguration
.
class
,
DispatcherServletAutoConfiguration
.
class
);
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"spring.mvc.throw-exception-if-no-handler-found:true"
);
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"spring.mvc.dispatch-options-request:true"
);
EnvironmentTestUtils
.
addEnvironment
(
this
.
context
,
"spring.mvc.dispatch-trace-request:true"
);
"spring.mvc.throw-exception-if-no-handler-found:true"
,
"spring.mvc.dispatch-options-request:true"
,
"spring.mvc.dispatch-trace-request:true"
,
"spring.mvc.servlet.load-on-startup=5"
);
this
.
context
.
refresh
();
DispatcherServlet
bean
=
this
.
context
.
getBean
(
DispatcherServlet
.
class
);
assertThat
(
bean
).
extracting
(
"throwExceptionIfNoHandlerFound"
)
.
containsExactly
(
true
);
assertThat
(
bean
).
extracting
(
"dispatchOptionsRequest"
).
containsExactly
(
true
);
assertThat
(
bean
).
extracting
(
"dispatchTraceRequest"
).
containsExactly
(
true
);
assertThat
(
new
DirectFieldAccessor
(
this
.
context
.
getBean
(
"dispatcherServletRegistration"
))
.
getPropertyValue
(
"loadOnStartup"
)).
isEqualTo
(
5
);
}
@Configuration
...
...
spring-boot-docs/src/main/asciidoc/appendix-application-properties.adoc
View file @
699d083c
...
...
@@ -337,6 +337,7 @@ content into your application; rather pick only the properties that you need.
spring.mvc.locale= # Locale to use.
spring.mvc.media-types.*= # Maps file extensions to media types for content negotiation.
spring.mvc.message-codes-resolver-format= # Formatting strategy for message codes. For instance `PREFIX_ERROR_CODE`.
spring.mvc.servlet.load-on-startup=-1 # Load on startup priority of the Spring Web Services servlet.
spring.mvc.static-path-pattern=/** # Path pattern used for static resources.
spring.mvc.throw-exception-if-no-handler-found=false # If a "NoHandlerFoundException" should be thrown if no Handler was found to process a request.
spring.mvc.view.prefix= # Spring MVC view prefix.
...
...
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