Spring MVC - Extending WebMvcConfigurationSupport Examples

Code Snippets Spring MVC 

@Configuration
@ComponentScan
public class AppConfig extends WebMvcConfigurationSupport {

@Override
@Bean
public RequestMappingHandlerMapping requestMappingHandlerMapping () {
RequestMappingHandlerMapping m = super.requestMappingHandlerMapping();
m.setAlwaysUseFullPath(true);
return m;
}
}
Original Post




@Configuration
@ComponentScan
public class AppConfig extends WebMvcConfigurationSupport {
@Override
@Bean
public RequestMappingHandlerMapping requestMappingHandlerMapping() {
RequestMappingHandlerMapping m = super.requestMappingHandlerMapping();
m.setDefaultHandler(new MyDefaultHandler());
return m;
}
}
Original Post




@Configuration
@ComponentScan
public class MyWebConfig extends WebMvcConfigurationSupport {

@Override
protected ConfigurableWebBindingInitializer getConfigurableWebBindingInitializer() {
ConfigurableWebBindingInitializer initializer = super.getConfigurableWebBindingInitializer();
initializer.setPropertyEditorRegistrar(propertyEditorRegistry -> {
SimpleDateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd");
propertyEditorRegistry.registerCustomEditor(Date.class,
new CustomDateEditor(dateFormatter, true));
});
return initializer;
}
}
Original Post




See Also