Rename property for registering default Servlet

As a follow-up for gh-21214, this commit renames the property to:

`"server.servlet.register-default-servlet=false"`

Closes gh-21214
This commit is contained in:
Brian Clozel
2020-04-29 18:42:50 +02:00
parent c7c01f8ab4
commit 692a8c47cc
4 changed files with 15 additions and 51 deletions

View File

@@ -38,7 +38,6 @@ import org.springframework.boot.web.server.Compression;
import org.springframework.boot.web.server.Http2;
import org.springframework.boot.web.server.Shutdown;
import org.springframework.boot.web.server.Ssl;
import org.springframework.boot.web.servlet.server.DefaultServlet;
import org.springframework.boot.web.servlet.server.Encoding;
import org.springframework.boot.web.servlet.server.Jsp;
import org.springframework.boot.web.servlet.server.Session;
@@ -227,8 +226,10 @@ public class ServerProperties {
*/
private String applicationDisplayName = "application";
@NestedConfigurationProperty
private final DefaultServlet defaultServlet = new DefaultServlet();
/**
* Whether to register the default Servlet with the container.
*/
private boolean registerDefaultServlet = true;
@NestedConfigurationProperty
private final Encoding encoding = new Encoding();
@@ -263,12 +264,16 @@ public class ServerProperties {
this.applicationDisplayName = displayName;
}
public Map<String, String> getContextParameters() {
return this.contextParameters;
public boolean isRegisterDefaultServlet() {
return this.registerDefaultServlet;
}
public DefaultServlet getDefaultServlet() {
return this.defaultServlet;
public void setRegisterDefaultServlet(boolean registerDefaultServlet) {
this.registerDefaultServlet = registerDefaultServlet;
}
public Map<String, String> getContextParameters() {
return this.contextParameters;
}
public Encoding getEncoding() {

View File

@@ -53,8 +53,7 @@ public class ServletWebServerFactoryCustomizer
map.from(this.serverProperties::getAddress).to(factory::setAddress);
map.from(this.serverProperties.getServlet()::getContextPath).to(factory::setContextPath);
map.from(this.serverProperties.getServlet()::getApplicationDisplayName).to(factory::setDisplayName);
map.from(this.serverProperties.getServlet().getDefaultServlet()::isRegistered)
.to(factory::setRegisterDefaultServlet);
map.from(this.serverProperties.getServlet()::isRegisterDefaultServlet).to(factory::setRegisterDefaultServlet);
map.from(this.serverProperties.getServlet()::getSession).to(factory::setSession);
map.from(this.serverProperties::getSsl).to(factory::setSsl);
map.from(this.serverProperties.getServlet()::getJsp).to(factory::setJsp);

View File

@@ -77,9 +77,9 @@ class ServletWebServerFactoryCustomizerTests {
@Test
void testCustomizeDefaultServlet() {
ConfigurableServletWebServerFactory factory = mock(ConfigurableServletWebServerFactory.class);
this.properties.getServlet().getDefaultServlet().setRegistered(true);
this.properties.getServlet().setRegisterDefaultServlet(false);
this.customizer.customize(factory);
verify(factory).setRegisterDefaultServlet(true);
verify(factory).setRegisterDefaultServlet(false);
}
@Test