[英]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" 您所做的修改不是存储在db中而是存储在您的文件夹中,例如,如果您已将文件存储在文件夹“ images”中
System.out.println(request.getRealPath("/")+"images\\"+"YourFileName"+".jpg");
的System.out.println(request.getRealPath( “/”)+ “图像\\” + “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? Struts2:如何在Webapp外部存储图像并将其路径保存到db?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.