We're in the process of switching to JavaConfig and we're having a problem getting multipart uploading to work
org.springframework.web.multipart.MultipartException: The current request is not a multipart request
Our configuration still uses security.xml and I tried following some suggestions
MultipartResolver and AbstractAnnotationConfigDispatcherServletInitializer
How to nicely handle file upload MaxUploadSizeExceededException with Spring Security
However, it isn't working.
@Configuration
@EnableWebMvc
@ComponentScan(basePackages = {"nl.project.controller"},includeFilters={
@ComponentScan.Filter(type=FilterType.ANNOTATION,value=Controller.class),
@ComponentScan.Filter(type=FilterType.ANNOTATION,value=RestController.class)
})
public class ServletConfig extends WebMvcConfigurerAdapter{
@Bean
public CommonsMultipartResolver filterMultipartResolver(){
CommonsMultipartResolver resolver = new CommonsMultipartResolver();
resolver.setMaxUploadSize(5000000);
resolver.setMaxInMemorySize(10000);
resolver.setDefaultEncoding("utf-8");
return resolver;
}
Any suggestions would be much appreciated!