You can set parameters on the whole ServletContext
by declaring a ServletContextInitializer
bean:
@Bean
public ServletContextInitializer initializer() {
return new ServletContextInitializer() {
@Override
public void onStartup(ServletContext servletContext) throws ServletException {
servletContext.setInitParameter("p-name", "-value");
}
};
}
Update: in Spring Boot 1.2 using a ServletContextInitializer
is no longer necessary. You can now configure a parameter on the ServletContext
in a single line in application.properties
:
server.context_parameters.p-name=-value
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…