且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

"不允许加载本地资源:file:///C:....jpg";Java EE Tomcat

更新时间:2022-11-16 23:25:55

sending tag <img src="c:imagesmypic.jpg"> 会导致用户浏览器访问图片从他的文件系统.如果您必须将图像存储在位于 c:images 的文件夹中,我建议创建一个 servlet,如images.jsp,它作为参数采用文件名,然后将 servlet 响应内容设置为image/jpg 然后从服务器位置加载图像字节并将其放入响应中.

sending tag <img src="c:imagesmypic.jpg"> would cause user browser to access image from his filesystem. if you have to store images in folder located in c:images i would suggest to create an servlet like images.jsp, that as a parameter takes name of a file, then sets servlet response content to an image/jpg and then loads bytes of image from server location and put it to a response.

但是你用什么来创建你的应用程序?它是纯servlet吗?春天?JSF?

But what you use to create your application? is it pure servlet? Spring? JSF?

这里你可以找到一些关于如何做的信息

Here you can find some info about, how to do it.