简体   繁体   English

方法getUploadedBlobs的异常行为

[英]Strange behavior with the method getUploadedBlobs

I've a problem with the methode blobstoreService.getUploadedBlobs(). 我对方法blobstoreService.getUploadedBlobs()有问题。 I've a JSP page in wich one I set an uploader like this : 我有一个JSP页面,我将这样设置一个上传器:

<formname='form'  action='<%= blobstoreService.createUploadUrl("/Edit_Engine") %>' method='POST' enctype='multipart/form-data' >
<input label='...' multiple='false' name='myFile' />
//...and multiple input for text
</form>

and I retrieve this code with my servlet : 然后使用servlet检索以下代码:

java.util.Map<String,BlobKey> blobs = blobstoreService.getUploadedBlobs(req);
BlobKey blobK  = blobs.get("myFiles[]"); //I don't know why I need to add the characters 's[]' at the end...

But the behavior is strange. 但是这种行为很奇怪。 The first time I upload an image, everything works. 第一次上传图片时,一切正常。 However, the second time, I send my form without uploading somehting (only text data), and then my java code finds a BlobKey. 但是,第二次,我发送的表单没有上传内容(仅文本数据),然后我的Java代码找到了一个BlobKey。 But this BlobKey seems to be the previous sended data, or a corrupted data. 但是此BlobKey似乎是先前发送的数据或损坏的数据。 I mean that not normal, because when I deploy this version on my localhost, if the form uploads no file the method getUploadedBlobs returns an empty HashMap. 我的意思是不正常,因为当我在本地主机上部署此版本时,如果表单未上传任何文件,则方法getUploadedBlobs将返回一个空的HashMap。 However, when I deploy on google servers, if the form uploads no file, the method getUploadedBlobs seems to return a HashMap with wrong data. 但是,当我在Google服务器上进行部署时,如果表单不上传任何文件,则方法getUploadedBlobs似乎会返回带有错误数据的HashMap。

Could you help me? 你可以帮帮我吗? Or tell me if this behaviro is normal... 或告诉我这个行为是否正常...

Many thanks, 非常感谢,

bat 蝙蝠

If you're getting a valid BlobKey, then myFiles[] is most likely the name given to the file input field in the form. 如果获取有效的BlobKey,则myFiles[]最有可能是表单中文件输入字段的名称。 Is that the case? 是这样吗 That seems like an odd name for an input field. 对于输入字段,这似乎是个奇怪的名字。 Are you using a template library to help generate HTML from the JSP? 您是否正在使用模板库来帮助从JSP生成HTML?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM