[英]Access files inside workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\
I have a spring web project which basically Test webApp and capture screenshot of pages.我有一个spring web 项目,它基本上测试 webApp 并捕获页面的屏幕截图。 The path of the saved image looks something like below:
保存图像的路径如下所示:
"\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps
\Demo\WEB-INF\Results\Test\1118015800\error\error_ST001_1.jpg"
I am trying to display the saved image on a JSP page and so far success has been elusive.我正在尝试在 JSP 页面上显示保存的图像,但到目前为止还没有成功。 I tried different combination of relative path also I tried to give absolute path but it doesn't work.
我尝试了相对路径的不同组合,我也尝试给出绝对路径,但它不起作用。 My image tag looks something like this
我的图像标签看起来像这样
<img src="<c:url value="/WEB-INF/Results/Test/1118015800/error/error_ST001_1.jpg" />" />
Does anyone have any idea on displaying the image?有没有人对显示图像有任何想法? Could it be because files are stored inside the .metadata folder of Eclipse workspace that I am not able to display any image?
可能是因为文件存储在 Eclipse 工作区的 .metadata 文件夹中,我无法显示任何图像?
This is because the WEB-INF
directory is special.这是因为
WEB-INF
目录比较特殊。 The web container won't serve files from that location - that behavior is defined in the Servlet Spec. Web 容器不会从该位置提供文件 - 该行为在 Servlet 规范中定义。
You can either create a servlet that takes requests from the client, loads images (eg using getResourceAsStream()
) and streams them back, or move the images to a different place in your web app hierarchy.您可以创建一个 servlet 来接受来自客户端的请求、加载图像(例如使用
getResourceAsStream()
)并将它们流式传输回来,或者将图像移动到 Web 应用程序层次结构中的不同位置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.