简体   繁体   English

IMG标签不带图像

[英]IMG tag does not bring image

I have a web application, where i am storing all the images in a folder which is totally outside WEB-INF folder or webroot folder. 我有一个Web应用程序,我将所有图像存储在完全不在WEB-INF文件夹或webroot文件夹之外的文件夹中。 When the jsp to display the image is called, before displaying it, i am moving the concerned image files to WEB-INF/images folder and then setting the path in the html IMG tag. 当调用显示图像的jsp时,在显示它之前,我将相关图像文件移动到WEB-INF / images文件夹,然后在html IMG标签中设置路径。 My question is 我的问题是

Is this good design? 这个设计好吗? Also even though the image is moved to WEB-INF/images folder, the page does not display the image always, it displays sometimes and sometimes it doesnt. 同样,即使将图像移至WEB-INF / images文件夹,页面也不会始终显示图像,有时甚至不显示。 I dont know how to debug this problem. 我不知道如何调试此问题。

I am using springs and spring security. 我正在使用弹簧和弹簧安全装置。

This is not a very good design. 这不是一个很好的设计。 In many cases, server will cache web application data so if the image was not there it will never find out that it appeared in place. 在许多情况下,服务器将缓存Web应用程序数据,因此,如果图像不存在,服务器将永远不会发现它已经就位。 That's, probably, causing the inconsistency that you observe as there may be other factors affecting caching. 这很可能导致您观察到不一致,因为可能还有其他因素影响缓存。

The right choice would be to provide a servlet that serves your image data upon request from the file. 正确的选择是提供一个servlet,该servlet根据文件的请求为您的图像数据提供服务。

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

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