adding image to eclipse web project

試著忘記壹切 提交于 2019-12-22 05:31:23

问题


Well, this is embarrasing...I can't seem to be able to add a humble image to a java web project in eclipse. What I did was that I created a folder called images inside WebContent, and then tried adding it in two ways, directly pasting it and using add/file, and advanced, which basically asks for a route to the image insider the hard drive.

The HTML syntax is here:

<img border="0" src="WebContent/images/network.jpg"
     alt="Pulpit rock" width="304" height="228">

I tried it with and without WebContent. I am sure there's something I'm missing, but after a couple hours decided to get help.

Thanks in advance for any assistance.


回答1:


You should in general try to avoid absolute paths. Specifically I believe from a normal web project you should try something like:

<img border="0" src="images/network.jpg"
     alt="Pulpit rock" width="304" height="228">

Which works like a charm for me.




回答2:


You have to add the image within the eclipse project structure for eclipse to package it and have it available on the webserver. Just having the image on your local file system doesn't work. To do this, drag and drop the file from your file system onto the eclipse project tree folder.



来源:https://stackoverflow.com/questions/19385955/adding-image-to-eclipse-web-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!