在Wicket 1.5中,我们以这种方式处理了上传的文件:
public UploadValuePage(PageParameters parameters) {
super(parameters);
Bytes maxSize = Bytes.kilobytes(20000);
ServletWebRequest swr = (ServletWebRequest) getRequest();
MultipartServletWebRequest mswr = swr.newMultipartWebRequest(maxSize, "uploadId");
FileItem item = mswr.getFile("fileInput").get(0);
// process item
}
但是在迁移到Wicket 6 之后,地图中没有文件。为什么呢?
答案 0 :(得分:1)
在网上搜索后我发现了这个:
http://wicketinaction.com/2012/11/uploading-files-to-wicket-iresource/
所以我们需要额外的一行,因为 Wicket 6.18.0 :
public UploadValuePage(PageParameters parameters) {
super(parameters);
Bytes maxSize = Bytes.kilobytes(20000);
ServletWebRequest swr = (ServletWebRequest) getRequest();
MultipartServletWebRequest mswr = swr.newMultipartWebRequest(maxSize, "uploadId");
mswr.parseFileParts(); // since Wicket 6.18.0
FileItem item = mswr.getFile("fileInput").get(0);
// process item
}