Spring 4 Java Config for MultipartResolver for Servlet 3.0

后端 未结 2 621
抹茶落季
抹茶落季 2021-02-08 15:52

I\'m taking an all-Java approach to Spring MVC configuration and cannot figure out how to associate a MultipartConfigElement with my DispatcherServlet

2条回答
  •  灰色年华
    2021-02-08 16:22

    Looks like you need this:

    ServletRegistration.Dynamic dispatcher = 
                container.addServlet("dispatcher", dispatcherServlet);
    dispatcher.setLoadOnStartup(1);
    dispatcher.addMapping("/*");
    
    dispatcher.setMultipartConfig(new MultipartConfigElement("/tmp", 1024*1024*5, 1024*1024*5*5, 1024*1024));
    

提交回复
热议问题