java - 如何避免在 wicket 请求结束时重置 FileUploadField

标签 java file-upload wicket

我有一个 wicket 表单,其中包含一个 FileUploadField 和一些更多的文本字段。当缺少必填字段时,验证将正确失败。然后,我选择上传的文件变成空的,所以我必须再次选择它,然后才能提交填写了所有必填字段的表单。

事实上,FileUploadField documentation说:

The model of this component is reset with null at the end of the request because FileUpload instances do not survive across requests since the input streams they point to will be closed. Because of this, the FileUpload instance should be processed within the same request as the form containing it was submitted.

有没有办法在表单验证失败时保留选中的文件?

最佳答案

没有。问题是浏览器会刷新它,并且出于(浏览器)安全原因,您不能在文件字段上设置默认值。

关于java - 如何避免在 wicket 请求结束时重置 FileUploadField,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6598646/

相关文章:

java - Android识别多个按钮

javascript - Dropzone.js 无法在 Windows 上上传文件

java - Tomcat 性能问题

java - 使用 Endless 适配器的 ListView

java - 什么类型的类实例化工厂类?

java - 如何使用 RESTEasy 代理客户端发送查询参数映射

javascript - blueimp 文件上传插件中的 maxFileSize 和 acceptFileTypes 不起作用。为什么?

c# - 进行服务器端验证而不丢失回发数据

java - Wicket @SpringBean 不创建可序列化代理

java - 在 Apache Wicket 中使用 ajax 处理单个输入字段