我有一个带有Spring Web Services的Spring Boot2应用程序,我尝试限制传入请求的最大大小。我尝试使用以下属性,但它不起作用。
server.tomcat.max-http-form-post-size
spring.servlet.multipart.max-request-size
spring.servlet.multipart.max-file-size你知道在Spring Boot2应用程序中使用Spring Web Services限制传入请求的最大大小的可行解决方案吗?在Spring Web Services documentation中,有关于Spring Web Services提供基于SunJRE1.6HTTP服务器的传输的信息。也许这是个问题?
发布于 2020-07-02 16:02:24
将此Bean添加到您的应用程序中并设置所需的大小(当前为10 MB)
// Set maxPostSize of embedded tomcat server to 10 MB (default is 2 MB, not large enough to support file uploads > 1.5 MB)
@Bean
EmbeddedServletContainerCustomizer containerCustomizer() throws Exception {
return (ConfigurableEmbeddedServletContainer container) -> {
if (container instanceof TomcatEmbeddedServletContainerFactory) {
TomcatEmbeddedServletContainerFactory tomcat = (TomcatEmbeddedServletContainerFactory) container;
tomcat.addConnectorCustomizers(
(connector) -> {
connector.setMaxPostSize(10000000); // 10 MB
}
);
}
};
}https://stackoverflow.com/questions/62691622
复制相似问题