Spring mvc Spring引导-自定义servlet的文件大小限制
如何为以编程方式注册的servlet设置上载文件大小限制 如果我使用web.xml,我会:Spring mvc Spring引导-自定义servlet的文件大小限制,spring-mvc,spring-boot,Spring Mvc,Spring Boot,如何为以编程方式注册的servlet设置上载文件大小限制 如果我使用web.xml,我会: <multipart-config> <max-file-size>52428800</max-file-size> <max-request-size>52428800</max-request-size> <file-size-threshold>0<</file-size-th
<multipart-config>
<max-file-size>52428800</max-file-size>
<max-request-size>52428800</max-request-size>
<file-size-threshold>0<</file-size-threshold>
</multipart-config>
52428800
52428800
0创建一个MultipartConfigElement
(与常规配置一样),并使用se MultipartConfig
方法将其设置为ServletRegistrationBean
。我认为这是可行的。
@Bean
public ServletRegistrationBean<CXMLServlet> servletRegistrationBean() {
return new ServletRegistrationBean<XMLServlet>(newXMLServlet(), "*.xml");
}