且构网

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

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

更新时间:2022-11-17 07:42:02

发送标签< img src =c:\\ \\ images\mypic.jpg> 会导致用户浏览器从他的文件系统访问图像。
如果你必须将图像存储在位于 c:\ images / 的文件夹中,我建议创建一个像images.jsp这样的servlet,作为参数取名一个文件,然后将servlet响应内容设置为image / jpg,然后从服务器位置加载图像的字节并将其放入响应。

sending tag <img src="c:\images\mypic.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.