Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
problem:
@RequestMapping(value = "preview/{fileName}", method = RequestMethod.GET)
public void previewFile(@PathVariable("fileName") String fileName, HttpServletRequest req, HttpServletResponse res) {
officeOnlinePreviewService.previewFile(fileName, req, res);
}
Originally fileName parameters are passed: userinfo.docx,
but the results received are: userinfo
This is obviously not what I want.
Solution:
@RequestMapping(value = "preview/{fileName:.+}", method = RequestMethod.GET)
public void previewFile(@PathVariable("fileName") String fileName, HttpServletRequest req, HttpServletResponse res) {
officeOnlinePreviewService.previewFile(fileName, req, res);
}
Parameters fileName write, represent any point (including the last point) it will be considered part of the argument:
{fileName:.+}