I have a RESTful spring based endpoint to get assets stored in a db to a javascript editor. The relevant parts boil down to:
@RestController
@RequestMapping(
I had required an extra step in my special case. I would like to add an extra information to @dirk-lachowski's great comment in case someone else needs. In my case I am importing an extension from WebMvcConfigurationSupport
class
@Configuration
@EnableWebMvc
@Import({ SearchWebMvcConfigurationSupport.class })
public class SearchSpringConfiguration extends WebMvcConfigurerAdapter {
@Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
configurer.favorPathExtension(false);
}
}
If you need to override requestMappingHandlerMapping
method then you also have to add m.setUseSuffixPatternMatch(false);
@Configuration
public class SearchWebMvcConfigurationSupport extends WebMvcConfigurationSupport {
@Override
@Bean
public RequestMappingHandlerMapping requestMappingHandlerMapping() {
RequestMappingHandlerMapping m = super.requestMappingHandlerMapping();
m.setAlwaysUseFullPath(true); // This makes your endpoints receive full path, including servlet mapping (you probably will not need this)
m.setUseSuffixPatternMatch(false);
return m;
}
}