这是使用Windows 7平台上的当地java服务器测试文档上载功能的问题。 由于问题随着Marko的投入而演变,我编辑了这个问题,这样,那些面临同样挑战的人不会浪费时间来了解演变的细节并尽快得出结论。
The challenge was to direct uploaded file to a folder outside of the WAR structure and successfully read it from there. For example: upload an image into c:/tmp/
and then redirect to a confirmation page that displays the image <img src="c:/tmp/test.jpg" />
. The upload worked but image would not be displayed. And based on Marko s input, this makes sense because browser sitting at localhost will refuse to load anything from local disk structure using c:
. Maybe these are security considerations similar to those with file input control where we cannot set a default path...
The following tag will work in a local establishing .html file but when pasted into a jsp, it得起工作。 而不同的是,浏览器利用当地幽灵进入垃圾场。
<img src="c:/tmp/test.jpg" />
<>Solutions
我认为,马尔科的回答在很大程度上界定了需要做些什么。 虽然我没有采取这种做法,但显然这是这样做的更好方法,我会接受,作为答案。 感谢 Marko!
对于那些不希望安装网络服务器并愿意用黑板生活的人,我已经做了些什么。 同样,我不想把档案上载到我的追回被盗资产结构中,因为当时我需要记住,在向服务器进行部署之前就清除了这一夹子。 但是,这一载荷仍需要能够使用,因此,我简单地创建了另一个 du子项目,并将这一载荷放在其网页上。 这是为了我的当地测试的目的。 唯一的核心是,在上载档案后,我需要更新Eclipse的“清米”项目。
config.properties
#for uploading files
fileUploadDirectory=C:/javawork/modelsite/tmp/WebContent
#for building html links
publicFileServicePrefix=http://localhost:8080/tmp
<img src="http://localhost:8080/tmp/test.jpg" /> // this works - tmp is the name of my dummy project.