简体   繁体   English

如何在jsp页面中显示图像?

[英]How to display an image in jsp page?

I know that this question is being asked a lot but I still have a problem. 我知道这个问题经常被问到,但是我仍然有一个问题。 I work on a web application using Apache-Tomcat and MySQL database to store the path of each image I want to display but it's not working so please if anyone write me down step by step how to display any image on a jsp page and where exactly I store my images for display on my webapp 我在使用Apache-Tomcat和MySQL数据库的Web应用程序上工作,以存储要显示的每个图像的路径,但是它不起作用,所以如果有人逐步写下我如何在jsp页面上显示任何图像以及确切显示位置,请我将图像存储在Webapp上显示

<div ><img src="<%=request.getContextPath() %>/images/logo.gif"  title="Your Title" /></div>

I don't see why this wouldn't work with regular html, so it would depend on what path you are retrieving from MySQL, meaning if it is the full URL to the file or a relative URL to the file. 我不明白为什么这不适用于常规html,所以这取决于您从MySQL检索的路径,即它是文件的完整URL还是文件的相对URL。

In the case of a full URL you just have to do the following: <img src="your_full_url_here"> In the case of a relative URL just prepend or append the missing information to reach the file, such as: <img src="your_relative_path' + restOfPathVariable> 对于完整的URL,您只需要执行以下操作: <img src="your_full_url_here">对于相对的URL,只需在丢失的信息之前或附加到文件中即可,例如: <img src="your_relative_path' + restOfPathVariable>

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

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