我正在 netbeans 中从事一个元素。我在 Dreamweaver 中设计了我的网页,并将代码复制到我的 netbeans 元素中的 jsp 中。然后我在WEB-INF下创建了一个images文件夹,存放我网页中使用的图片。我还将我的“img src”的路径更改为该本地路径。但是当我在浏览器中运行它时,图像不会显示!
请帮忙...
这是我的包裹
|我的元素 |网络信息 |图像 |网络.xml |home.jsp
这是我的示例代码:
<td width="610"><div id="logom"><img src="WEB-INF/images/webDes.png" width="323" height="167" alt="logomain" /></div></td>
最佳答案
根据 JSR-000315 , 第 121 页:
A special directory exists within the application hierarchy named "WEB-INF"...no other files contained in the WEB-INF directory may be served directly to a client by the container.
和第 122 页:
any requests to access the resources in META-INF directory must be returned with a SC_NOT_FOUND(404) response.
结论: 通常,您不会将 CSS、HTML、JavaScript 等静态资源放入 META-INF/或 WEB-INF/中,尤其是当元素是从 Dreamweaver 导入(?) 时。现在我明白有些人可能不同意我的看法,因为实际上有一些方法(通过 JEE 或框架)可以实现该目标,我不得不承认它们是正确的。虽然根据我假设的您的背景,我认为您没有在元素中加入 JEE 或任何其他框架。因此,在您的情况下,您可能只想避免直接使用 WEB-INF/(以及 META-INF/)。
关于java - 图像未出现在 netbeans 的 jsp 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21218371/