我有一个 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/