Jsp 在java中获取url后未显示图像
我得到了图像的路径,我正试图通过标记在jsp上显示它,但图像是bot来的。我还尝试给src分配一个静态代码。下面是我的代码Jsp 在java中获取url后未显示图像,jsp,Jsp,我得到了图像的路径,我正试图通过标记在jsp上显示它,但图像是bot来的。我还尝试给src分配一个静态代码。下面是我的代码 <img alt="" src="c:/indiapod_uploads/uploadedFiles/14RC0199\Desert.jpg" height="20px"width="20px"> String strUploadPathBase = request.getServletContext().getRealPath("/")+"Example
<img alt="" src="c:/indiapod_uploads/uploadedFiles/14RC0199\Desert.jpg" height="20px"width="20px">
String strUploadPathBase = request.getServletContext().getRealPath("/")+"Example\\image-folder\\" ;
String strfileName = request.getParameter("fileName");
File file = new File(strUploadPathBase+"uploadedFiles\\"+strPatientNumber+"\\"+strfileName);
字符串strUploadPathBase=request.getServletContext().getRealPath(“/”+“示例\\图像文件夹\\”;
字符串strfileName=request.getParameter(“文件名”);
File File=new File(strUploadPathBase+“uploadedFiles\\”+strPatientNumber+“\\”+strfileName);
请提供帮助。一个解决方案是,您需要有一个单独的Servlet来流式处理图像文件。将此Servlet映射到URL模式,例如“/upload/*”。在img标记中,使用像/upload/filename.jpg这样的路径
在这里,了解java.io包中的流和servlet映射非常重要 尝试将路径更改为相对于应用程序上下文。我已尝试此操作,但现在我的文件未上载编辑看起来您希望显示用户上载的图像。图像文件不是应用程序的一部分。