我已经看到了很多关于同一问题的话题。但是,所有解决方案都不适用于我。问题很简单:我的图像未显示在页面上,而是被替换为替代文本。
我的图像的路径: WebContent / LIB / image / my-image.png-
这不在WEB-INF文件夹中(好的做法)。
-我尝试使用其他图像(.jpg),但失败了。我看到很多人解释说,真正的问题是道路。我尝试了所有这些路径,但是任何人都在工作:
<img src='<c:url value="/LIB/image/my-image.png"/>' alt="KO"/>
// http://localhost:8080/3JVA-Project-SupTrip/WebContent/LIB/image/%3Cc:url%20value=%22/LIB/image/my-image.png%22/%3E
<img src="LIB/image/my-image.png" alt="KO"/>
// http://localhost:8080/3JVA-Project-SupTrip/WebContent/LIB/image/LIB/image/my-image.png
<img src="/LIB/image/my-image.png" alt="KO"/>
// http://localhost:8080/LIB/image/my-image.png
<img src="../LIB/image/my-image.png" alt="KO"/>
// http://localhost:8080/3JVA-Project-SupTrip/WebContent/LIB/LIB/image/my-image.png
<img src="<%=request.getContextPath()%>/LIB/image/my-image.png" alt="KO"/>
// http://localhost:8080/3JVA-Project-SupTrip/LIB/image/my-image.png
<img src="<%=request.getContextPath()%>/WebContent/LIB/image/my-image.png" alt="KO"/>
// http://localhost:8080/3JVA-Project-SupTrip/WebContent/LIB/image/my-image.png
这是我的图像的逻辑URI: http:// localhost:8080 / 3JVA-Project-SupTrip / WebContent / LIB / image / my-image.png
我真的需要您的帮助,谢谢伙伴。
编辑:使用URI添加一些注释(最后一个听起来很完美,但是不起作用)
例如,这包括作品:
<!-- Main CSS -->
<style type="text/css">
<%@ include file="../LIB/css/main.css" %>
</style>
结构:
-3JVA-Project-SupTrip
--build
--src
--WebContent
--- LIB
---- image
----- my-image.png
--- META-INF
--- WEB-INF
请使用此路径,
<img src="/LIB/image/my-image.png" alt="KO"/>
应该可以,因为在我看来,它可以正常工作。
另外,如果您愿意的话,可以将名称从“ LIB”更改为“ assets”。
编辑:
<input type="image" src="LIB/image/ttt.jpg"/>
编辑重复
<img src="LIB/image/bg.jpg" alt="Smiley face" height="42" width="42">
请确认,它在所有情况下都有效。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句