我的配置在这里。
我根据帖子中的答案进行了一些修改。
filterMultipartResolver
@Bean
public StandardServletMultipartResolver filterMultipartResolver() {
return new StandardServletMultipartResolver();
}
Run Code Online (Sandbox Code Playgroud)
AppInitializer
public class AppInitializer implements WebApplicationInitializer {
@Override
public void onStartup(final ServletContext servletContext) throws ServletException {
// Create the 'root' Spring application context
final WebApplicationContext context = getContext();
// Manage the lifecycle of the root application context
servletContext.addListener(new ContextLoaderListener(context));
final Dynamic dispatcher = servletContext.addServlet("DispatcherServlet", new DispatcherServlet(context));
dispatcher.setMultipartConfig(getMultipartConfigElement());
dispatcher.setLoadOnStartup(1);
dispatcher.addMapping("/");
}
private static AnnotationConfigWebApplicationContext getContext() {
final AnnotationConfigWebApplicationContext context = new AnnotationConfigWebApplicationContext();
context.register(AppConfig.class);
return context;
}
private …Run Code Online (Sandbox Code Playgroud)