更新时间:2023-01-15 08:28:15
您可以使用 TomcatContextCustomizer
来访问管理器并应用必要的配置:
You can use a TomcatContextCustomizer
to access the manager and apply the necessary configuration:
@Bean
public EmbeddedServletContainerFactory servletContainer() {
TomcatEmbeddedServletContainerFactory tomcat = new TomcatEmbeddedServletContainerFactory();
tomcat.addContextCustomizers(new TomcatContextCustomizer() {
@Override
public void customize(Context context) {
if (context.getManager() instanceof StandardManager) {
((StandardManager) context.getManager()).setPathname("");
}
}
});
return tomcat;
}