GWT - 从 FormPanel 上传文件后返回对象吗?
我正在使用 FileUpload 和 FormPanel 上传文件,在服务器上我使用上传文件中的数据生成一个列表。 问题是我需要在客户端上显示这个列表,但我找不到在普通 HttpServlet 中使用 GWT 序列化来序列化它的方法。仅在无法处理 FormPanel 请求的 RemoteServiceServlet 中。
另外,在从 SubmitCompleteEvent 获取对象后,我什至不知道如何在客户端反序列化该对象。
I'm uploading a file using FileUpload and a FormPanel, on the server I generate a List using the data from the uploaded file.
The problem is that I need to display this List on the client, but I can't find a way to serialize it using GWT's serialization in a normal HttpServlet. Only in RemoteServiceServlets which can't process a FormPanel's request.
Also, I wouldn't even know how to deserialize the Object on the client after I got it from the SubmitCompleteEvent.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我在我工作的公司为此开发了一个定制解决方案。它使用了 gwt-upload 项目中的一些代码。我所做的背后的想法是:
我已经声明静态处理临时上传文件的结构。这样,它对于 servlet 和 GWT 控制器来说是全局可见的。如果您不喜欢它,您还可以在上下文侦听器中进行一些初始化,并在应用程序上下文中存储对全局文件上传系统的引用。这样,GWT 服务实现和servelt 实现无论如何都可以访问它。
I've developed a custom solution for this in the company I work for. It uses some code from the gwt-upload project. The idea behind what I've made is:
I've declared the structure for handling the temporal uploaded files statically. That way it's globally visible for the servlet and for the GWT Controller. If you don't like it you could also do some initialization in a contextlistener and store a reference to the global file uploading system in Application context. That way the GWT Service implementation and the servelt implementation could access it anyway.
我建议不要尝试使用 GWT-RPC 序列化,而是使用 JSON 进行序列化服务器上的列表。
Instead of trying to use GWT-RPC serialization, I would suggest using JSON to serialize the list on the server.