【发布时间】:2018-11-06 10:07:09
【问题描述】:
我正在开发用于管理图像的文件上传小部件。
我希望Spring MVC中可以通过@PathVariable接收图片路径,比如http://localhost:8080/show/img/20181106/sample.jpg而不是http://localhost:8080/show?imagePath=/img/20181106/sample.jpg。
但是/会被Spring MVC解析,访问时总是返回404。
有什么好的办法吗?
【问题讨论】:
-
你应该使用这种格式
RequestMappinghttp://localhost:8080/show/{imagePath:.+} -
如果
imagePath中有多个/,这种格式仍然返回404。
标签: java spring spring-mvc path-variables