-
Notifications
You must be signed in to change notification settings - Fork 64
Config Spring Java Config
ralscha edited this page Oct 2, 2012
·
4 revisions
A setup with JavaConfig still needs the DispatcherServlet described here. The rest of the configuration is a translation of the XML Setup.
@Configuration
@EnableWebMvc
@ComponentScan(basePackages = "ch.ralscha.extdirectspring"}
public class WebConfig {
@Bean
public MultipartResolver multipartResolver() {
CommonsMultipartResolver resolver = new CommonsMultipartResolver();
resolver.setMaxUploadSize(100000);
return resolver;
}
//some more configuration
}
The MultipartResolver is only needed for file uploads. The CommonsMultipartResolver needs two additional libraries (commons-fileupload and commons-io)
In a Servlet 3.0 container you could use the StandardServletMultipartResolver. The two libraries commons-fileupload and commons-io are no longer needed.
@Bean
public MultipartResolver multipartResolver() {
return new StandardServletMultipartResolver();
}
If you use this configuration don't forget to enable multipart support on the DispatcherServlet (<multipart-config />
). See XML Setup.
- Introduction
- Changelog 1.7.x
- Setup Maven
- Configuration
- Server Methods
- Model Generator
- Model Generator APT
- Development
- Links