gpt4 book ai didi

java - jsp中无法访问jpg

转载 作者:行者123 更新时间:2023-12-01 20:18:38 24 4
gpt4 key购买 nike

我的webcontent/images文件夹中有两个图像文件the_logo.jpglogo.png

能够访问 .png 文件

<img alt="Powerpay1" src="./images/logo.png"  width="250" height="50" />

但是无法访问.jpg文件

<img alt="Powerpay" src="./images/the_logo.jpg"  width="250" height="50" />

我该如何解决这个问题?如果需要任何其他信息,请随时询问。

注意:我使用的是 Apache tomcat。

最佳答案

使用

<img alt="Powerpay1" src="../images/logo.png"  width="250" height="50" />

<img alt="Powerpay1" src="../images/the_logo.jpg" width="250" height="50" />

This code will take the cursor to the previous folder.

If you have two nested folder, use ../../ or three nested folders, use ../../../and so on to go to the root of the directory and browse respectly.

而不是

<img alt="Powerpay1" src="./images/logo.png"  width="250" height="50" />

<img alt="Powerpay1" src="./images/the_logo.jpg" width="250" height="50" />
<小时/>

使用 scriptlet 来实现此目的的另一种最佳方法

例如:

<%
String base = request.getContextPath() + "/";
if (base == null || base.isEmpty()) {
base = "/";
}
%>

<img alt="Powerpay1" src="<%=base%>images/logo.png" width="250" height="50" />

关于java - jsp中无法访问jpg,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45276798/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com