Skip to content

Provide a property to change loadOnStartup for DispatcherServlet. #2481

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
izeye opened this issue Feb 11, 2015 · 6 comments
Closed

Provide a property to change loadOnStartup for DispatcherServlet. #2481

izeye opened this issue Feb 11, 2015 · 6 comments
Assignees
Labels
type: enhancement A general enhancement
Milestone

Comments

@izeye
Copy link
Contributor

izeye commented Feb 11, 2015

It would be nice to provide a property to change loadOnStartup for DispatcherServlet.

In Spring Boot, loadOnStartup for DispatcherServlet is -1.

Is there any reason to use -1 as default value?

@philwebb
Copy link
Member

-1 is the default, same as javax.servlet.ServletRegistration. Any specific reason why you want something else as the default?

@philwebb philwebb added this to the 1.3.0 milestone Feb 23, 2015
@philwebb philwebb added the type: enhancement A general enhancement label Feb 23, 2015
@izeye
Copy link
Contributor Author

izeye commented Feb 24, 2015

@philwebb I just want to make sure

that the DispatcherServlet has been loaded before the first request.

Although -1 doesn't make any problem for me, I just thought it's more natural.

Am I wrong?

And in the Spring framework document, every example has 1 for load-on-startup as follows:

    <servlet>
        <servlet-name>example</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

I just thought it's sort of recommendation (this could be a wrong assumption).

@philwebb
Copy link
Member

The lifecycle with Spring Boot's embedded servlet containers is a little different to WAR based deployments. With WAR deployments, the Servlet creates the application context. With embedded containers, the application context is created first and contains the servlet container. Spring Boot should also ensure that no requests can be processed before the container is fully started.

I think the property option could be useful and it's something we can consider for 1.3.

@izeye
Copy link
Contributor Author

izeye commented Feb 24, 2015

@philwebb Thanks for the explanation.

@philwebb philwebb modified the milestones: 1.4.0, 1.3.0.RC1 Jul 10, 2015
@benneq
Copy link

benneq commented Aug 12, 2015

any progress on this? i'd like to preload my dispatcher servlet, too.

@wilkinsona
Copy link
Member

@benneq The issue's currently targeted at 1.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

5 participants