Avoid file extension detection in Spring MVC request mapping with floating point number in URI

前端 未结 3 913
时光取名叫无心
时光取名叫无心 2021-01-15 13:07

I used Spring Boot to implement a REST application. I have one resource that is mapped like this

@RequestMapping(value = \"/{fromLat}/{fromLon}/{toLat}/{toL         


        
3条回答
  •  一个人的身影
    2021-01-15 13:52

    Did you try to set:

    1) Content-Disposition: inline; -> you can use:

    return new ResponseEntity(body, headers, statusCode); and set Content-Disposition in headers. Look here: How to set 'Content-Disposition' and 'Filename' when using FileSystemResource to force a file download file? and Return a stream with Spring MVC's ResponseEntity

    2) text/x-json - Experimental MIME type for JSON before application/json got officially registered.

    @RequestMapping(value = "/{fromLat}/{fromLon}/{toLat}/{toLon:.+}", method = {RequestMethod.GET},
                    produces = {"text/x-json"})
    

    It will try to display the content instead of downloading it.

    Hope it will help.

提交回复
热议问题