getUploadedBlobs 方法的奇怪行为
我的方法 blobstoreService.getUploadedBlobs() 有问题。我有一个 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>
并且我使用 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...
但行为很奇怪。我第一次上传图像时,一切正常。但是,第二次,我发送表单而不上传任何内容(仅文本数据),然后我的 java 代码找到了 BlobKey。但是这个BlobKey似乎是以前发送的数据,或者是损坏的数据。 我的意思是这不正常,因为当我在本地主机上部署此版本时,如果表单未上传任何文件,则 getUploadedBlobs 方法将返回一个空的 HashMap。但是,当我在谷歌服务器上部署时,如果表单没有上传文件,则 getUploadedBlobs 方法似乎返回一个包含错误数据的 HashMap。
你能帮我吗?或者告诉我这种行为是否正常......
非常感谢,
蝙蝠
I've a problem with the methode blobstoreService.getUploadedBlobs(). I've a JSP page in wich one I set an uploader like this :
<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 :
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. But this BlobKey seems to be the previous sended data, or a corrupted data.
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. However, when I deploy on google servers, if the form uploads no file, the method getUploadedBlobs seems to return a HashMap with wrong data.
Could you help me? Or tell me if this behaviro is normal...
Many thanks,
bat
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您获得有效的 BlobKey,则
myFiles[]
很可能是为表单中的文件输入字段指定的名称。是这样吗?对于输入字段来说,这似乎是一个奇怪的名称。您是否使用模板库来帮助从 JSP 生成 HTML?If you're getting a valid BlobKey, then
myFiles[]
is most likely the name given to the file input field in the form. 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?