在Spring + Wicket中上传文件 [英] Uploading files in Spring+Wicket
问题描述
当谷歌搜索对于这个问题的答案,我看到/ WEB-INF / some-directory应该用作上传位置的建议?
是这个最佳实践的原因吗?
这个位置可以通过Web应用程序写入?
当部署新版本的Web应用程序时,该位置会发生什么?
可以/应该使用任何其他目录?
谢谢
使用WEB-INF的子目录:
-
通过HTTP不可见
b $ b -
您的应用程序通常具有对其的写入权限
我宁愿推荐使用可配置的外部目录(例如,配置在上下文参数或应用程序配置文件中);这样你就可以对目录的权限进行细化控制。 apache.org/apidocs/1.4/org/apache/wicket/markup/html/form/upload/FileUploadField.htmlrel =nofollow> FileUploadField 组件,它给你一个 FileUpload 对象,你可以 writeTo 您的服务器上的文件。 it is not visible through HTTP
your application typically has write access to it
您可能还想要配置/检查要接受的文件的最大大小。在Tomcat中,这是通过Connector的maxPostSize属性完成的(请参阅 HTTP连接器)
What are the steps required for enabling a Java web application (Developed using Spring + Wicket) to accept client file uploads to a specific directory on the server.
While Googling for answers to this question I see suggestions that /WEB-INF/some-directory should be used as the upload location?
Is the reason for this best practice?
Is this location writable by the web application?
What happens to this location when a new version of the web application is deployed?
Can/Should any other directory be used?
Thanks
Two possible reasons for the use of a subdirectory of WEB-INF:
I would rather recommend using a configurable, external directory (e.g configured in a context parameter or en application config file); this way you have fine grained control over the permissions of the directory.
AFAIK, file upload in Wicket is provided by the FileUploadField component, which gives you a FileUpload object that you can writeTo a file on your server.
You might also want to configure/check the maximum size for the files you want to accept. In Tomcat, this is done through the maxPostSize attribute of a Connector (see The HTTP Connector)
这篇关于在Spring + Wicket中上传文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!