Skip to content
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

[doc] AbstractDispatcherServletInitializer support DispatcherServlet from Root Context [SPR-16041] #20590

Closed
spring-issuemaster opened this issue Oct 3, 2017 · 3 comments

Comments

Projects
None yet
2 participants
@spring-issuemaster
Copy link
Collaborator

commented Oct 3, 2017

Rob Winch opened SPR-16041 and commented

It would be nice if AbstractDispatcherServletInitializer made it simple to register the DispatcherServlet using the root ApplicationContext


Affects: 4.3.11, 5.0 GA

Issue Links:

  • #15982 AbstractAnnotationConfigDispatcherServletInitializer does not allow consolidating all configuration into the "root" context

Referenced from: commits 32d78e6

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Oct 17, 2017

Rossen Stoyanchev commented

Note that the sub-class AbstractAnnotationConfigDispatcherServletInitializer has already allowed this for quite some time (see #15982). So all that any sub-class would have to do is create an instance of a WebApplicationContext. We could probably pre-implement createServletApplicationContext to do just that and feature more prominently the fact that you can put all configuration in the root context.

@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Oct 17, 2017

Rob Winch commented

Rossen Stoyanchev I must have messed something up previously because the use case I wanted appears to work. For example, the following does appear to work:

public class WebInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
	@Override
	protected Class<?>[] getRootConfigClasses() {
		return new Class[] { WebMvcConfig.class, SecurityConfig.class };
	}

	@Override
	protected Class<?>[] getServletConfigClasses() {
		return null;
	}

	@Override
	protected String[] getServletMappings() {
		return new String[] { "/" };
	}
}
@spring-issuemaster

This comment has been minimized.

Copy link
Collaborator Author

commented Oct 18, 2017

Rossen Stoyanchev commented

I've done updates to the Javadoc and reference to better document how to have a single application context in both Java config and web.xml. Aside from that everything works as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.