mysterin / question_and_answer

1 stars 0 forks source link

springmvc 获取 URL 参数包含点. #118

Closed mysterin closed 5 years ago

mysterin commented 5 years ago

比如这个 URL:

test-url/download-report/xxx.docx

后台匹配:

@RequestMapping("download-report/{docname}")
public ResponseEntity<byte[]> downloadReport(@PathVariable String docname)

这样 docname 只能获取 xxx 这个值, 后面的 .docx 是拿不到的, 所以要改成这样获取:

@RequestMapping("download-report/{docname:.+}")
public ResponseEntity<byte[]> downloadReport(@PathVariable String docname)