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-projects-issues opened this issue Oct 3, 2017 · 3 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: task A general task
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues 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:

Referenced from: commits 32d78e6

@spring-projects-issues
Copy link
Collaborator Author

spring-projects-issues 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-projects-issues
Copy link
Collaborator Author

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-projects-issues
Copy link
Collaborator Author

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
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: task A general task
Projects
None yet
Development

No branches or pull requests

2 participants