RESTful API handles the problem that the URL cannot be obtained

Use RESTful URLs. However, when processing URLs with dots, the background cannot get them correctly, such as the URL localhost:8080/file/1234.jpg. The background only gets 1234, but the .jpg suffix is ​​not available. Reason: Spring regards the dot as an extended separator, equivalent to /, so it cannot be obtained.

solution:

The matching pattern of /{path:.+} can be used in RequestMapping to get it correctly ( path is the parameter name), and so on in other cases

E.g:

@RequestMapping(value = "getFile/{folder}/{fileName:.+}*", method = RequestMethod.GET)
    public void getFile(HttpServletResponse response, @PathVariable String folder,
                        @PathVariable String fileName)
    {
    }

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325529571&siteId=291194637