繁体   English   中英

如何在Spring Controller中提供文件的动态路径

[英]How to provide dynamic path to a file in Spring Controller

像我们在独立Java应用程序中一样,有什么方法可以在Spring Controller中传递参数

    String filePath=args[0] 

这是我要提供文件路径的以下代码

    @RequestMapping(value="/someUrl/", method=RequestMethod.GET)

    String imageFilePath=? //Is there any way to pass the arguments here

使用@PathVariable批注。
在您的jsp中,通过发送一些变量来发送请求,例如

action=/${someurl}/ 

然后,您可以在控制器中使用它,例如:

@RequestMapping(value="/{someurl}")
functionName (@PathVariable String yourUrl)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM