Only solve the problem before the dot data taken when a bit number reception parameters @PathVariable

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.
This link: https://blog.csdn.net/tanwenfang/article/details/94457265

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:.+}

Guess you like

Origin blog.csdn.net/tanwenfang/article/details/94457265