I used Spring Boot to implement a REST application. I have one resource that is mapped like this
@RequestMapping(value = "/{fromLat}/{fromLon}/{toLat}/{toLon:.+}", method = {RequestMethod.GET},
produces = {"application/json"})
Thus the path contains coordinates and a request looks like this
$ curl -I -X GET http://localhost:8085/foobar/53.481297/9.900539/53.491691/9.946046
Unfortunatly the last end is interpreted as a file extension which leads to a response header that offers a file download instead of just the plain data.
Content-Disposition: attachment;filename=f.txt
I thought I could handle the situation with a custom WebMvcConfigurerAdapter Bean (and without @EnableWebMvc) annotation like explained here.
public class CustomWebMvcConfigurerAdapter extends WebMvcConfigurerAdapter {
@Override
public void configureContentNegotiation(ContentNegotiationConfigurer configurer) {
configurer.favorPathExtension(false);
}
}
But that does not do the trick. Unfortunatly the detected file extension is not fix - thus I can not use a rule for a fix extension.
How can I configure the system to just respond with the content and without the Content-Disposition header (which leads to an f.txt download)? I would not like to use a slash ("/") at the end.
I already looked at the following ressource