Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/apache-flex/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/powerbi/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring:我想在jsp或controller中获取资源的相对路径或完整路径_Spring_Resources_Path_Relative Path - Fatal编程技术网

Spring:我想在jsp或controller中获取资源的相对路径或完整路径

Spring:我想在jsp或controller中获取资源的相对路径或完整路径,spring,resources,path,relative-path,Spring,Resources,Path,Relative Path,我有一些用户上传的图片存储在“resource/pics”中,我想在jsp中显示,但路径总是错误的。 我试过了 但它返回: jndi:/default-host/mvc/resources/pics/bec7838a-55dc-4f8e-86c1-fb9e9067909d.jpg 我的资源在servlet-context.xml中配置 <mvc:resources mapping="/resources/**" location="/resources/" /> 我的资源目录

我有一些用户上传的图片存储在“resource/pics”中,我想在jsp中显示,但路径总是错误的。 我试过了

但它返回:

jndi:/default-host/mvc/resources/pics/bec7838a-55dc-4f8e-86c1-fb9e9067909d.jpg
我的资源在servlet-context.xml中配置

<mvc:resources mapping="/resources/**" location="/resources/" />

我的资源目录输入:/webapp/resources

因此,我的/resources/pics/bec7838a-55dc-4f8e-86c1-fb9e9067909d.jpg位于…/webapp/resources/pics/bec7838a-55dc-4f8e-86c1-fb9e9067909d.jpg

我不需要“jndi:/defaulf主机”。我知道我可以使用子字符串来创建它,但我认为spring框架应该提供一些函数来将资源获取到路径或URL

我想将此资源路径获取给jsp中的用户或jsp页面中使用的控制器

<img src="${pageContext.servletContext.contextPath}/resources/pics/${pictureName}"/>

spring项目中文件夹“resource/pics”的位置是什么?在servlet上下文I config中
<img src="${pageContext.servletContext.contextPath}/resources/pics/${pictureName}"/>
model.addAttribute("pictureName", "picture.jpg")