简体   繁体   English

图像未显示在 eclipse oxyegen 的 webapp maven 项目中?

[英]Image not showing in webapp maven project in eclipse oxyegen?

I have a simple code snippet to show two buttons and an image, but it's only showing the buttons and a alt part of the <img> tag.我有一个简单的代码片段来显示两个按钮和一个图像,但它只显示按钮和<img>标记的 alt 部分。 It does show the image when the whole address is given.当给出整个地址时,它会显示图像。

Where should I store the image?我应该在哪里存储图像? I have tried in:我试过:

  • Project main folder (/Shopping)项目主文件夹(/Shopping)
  • /Shopping/src/main/webapp/WEB-INF/bootstrap /Shopping/src/main/webapp/WEB-INF/bootstrap
  • /Shopping/src/main/webapp/WEB-INF /Shopping/src/main/webapp/WEB-INF
  • /Shopping/src /购物/来源

 <!-- Bootstrap CDN, normally stored on webserver --> <link href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet"> <div class="header"> <div class="container-fluid"> <div class="col-lg-12"> <input type="search"> <input type="submit" value="search"> <button class="btn btn-success">Login</button> <button class="btn btn-primary">Register</button> <img border="0" src="images\\logo.png" alt="logo" width="304" height="228" /> </div> </div> </div>

Please read this tutorial on HTML File Paths.请阅读有关 HTML 文件路径的本教程

You're now referring to an image that is located in /images , a subdirectory of the folder in which your html-page is saved.您现在指的是位于/images ,这是保存 html 页面的文件夹的子目录。 If there is no such directory then the image will not be displayed.如果没有这样的目录,则不会显示图像。

So if your webpage is stored in https://yourdomain.com/index.html , then your image should be stored in https://yourdomain.com/images/logo.png .因此,如果您的网页存储在https://yourdomain.com/index.html ,那么您的图像应存储在https://yourdomain.com/images/logo.png

Please keep in mind that you should use a forward slash / , instead of a backward slash \\ when defining an images location.请记住,在定义图像位置时,您应该使用正斜杠/ ,而不是反斜杠\\

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM