无法加载JSP映像 [英] JSP image couldn't be loaded
本文介绍了无法加载JSP映像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图将绝对路径放在jsp标记中.但是它不会显示图像.
I have tried to put absolute path in jsp tag. But it doesn't display the image.
<div class="container">
<img src="<c:url value='${pageContext.request.contextPath}/images/default-
user-image.png'/>" alt="userImage" />
</div>
推荐答案
JSTL <c:url>
标记具有context
属性(可选),并且默认情况下将当前应用程序设置为上下文.
JSTL <c:url>
tag has the context
attribute ( optional) and it is set the current application as the context by default.
因此,您可以这样使用而无需contextPath
:
So, you can use like this without contextPath
:
<c:url value='/images/default-user-image.png'/>
第二,要使用Spring提供静态资源,请检查您的静态处理程序是否正常工作.
Secondly, To serve static resources with Spring, check your static handlers whether it works correctly or not.
对于您的示例,以XML添加以下映射可能有效.
For your example, add the following mapping in XML might work.
<mvc:resources mapping="/images/**" location="/images/" />
这篇关于无法加载JSP映像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文