简体   繁体   中英

storing image as physical file on server

我在存储从某些url获取的图像时遇到问题。问题是如何在服务器上存储图像以及在数据库上给出什么路径。如何将图像作为物理文件存储在服务器上,然后在jsp上检索该图像页。

You should make a folder in the project, use this folder to store physical files and give its path in action.

Online example is here to store image from database to specific folder.

Download Code here - Project URL

Your modification is not to store in db but store in your folder, for example if you have stored files in folder "images"

System.out.println(request.getRealPath("/")+"images\\"+"YourFileName"+".jpg");

Above code will give you path of physical path on server.

Your Question is possible duplicate of

Struts2: How to store images outside of the webapp and save its path to the db?

Storing Images in java project dynamically

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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