Skip to content

Commit c1c07bb

Browse files
committed
AbstractDispatcherServletInitializer allows for registering any FrameworkServlet subclass
Issue: SPR-13616
1 parent 9bed389 commit c1c07bb

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

spring-webmvc/src/main/java/org/springframework/web/servlet/support/AbstractDispatcherServletInitializer.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import org.springframework.web.context.AbstractContextLoaderInitializer;
3333
import org.springframework.web.context.WebApplicationContext;
3434
import org.springframework.web.servlet.DispatcherServlet;
35+
import org.springframework.web.servlet.FrameworkServlet;
3536

3637
/**
3738
* Base class for {@link org.springframework.web.WebApplicationInitializer}
@@ -90,7 +91,7 @@ protected void registerDispatcherServlet(ServletContext servletContext) {
9091
"createServletApplicationContext() did not return an application " +
9192
"context for servlet [" + servletName + "]");
9293

93-
DispatcherServlet dispatcherServlet = createDispatcherServlet(servletAppContext);
94+
FrameworkServlet dispatcherServlet = createDispatcherServlet(servletAppContext);
9495
dispatcherServlet.setContextInitializers(getServletApplicationContextInitializers());
9596

9697
ServletRegistration.Dynamic registration = servletContext.addServlet(servletName, dispatcherServlet);
@@ -132,9 +133,12 @@ protected String getServletName() {
132133
protected abstract WebApplicationContext createServletApplicationContext();
133134

134135
/**
135-
* Create a {@link DispatcherServlet} with the specified {@link WebApplicationContext}.
136+
* Create a {@link DispatcherServlet} (or other kind of {@link FrameworkServlet}-derived
137+
* dispatcher) with the specified {@link WebApplicationContext}.
138+
* <p>Note: This allows for any {@link FrameworkServlet} subclass as of 4.2.3.
139+
* Previously, it insisted on returning a {@link DispatcherServlet} or subclass thereof.
136140
*/
137-
protected DispatcherServlet createDispatcherServlet(WebApplicationContext servletAppContext) {
141+
protected FrameworkServlet createDispatcherServlet(WebApplicationContext servletAppContext) {
138142
return new DispatcherServlet(servletAppContext);
139143
}
140144

0 commit comments

Comments
 (0)