将图像放置在对象中,通过rpc发送对象,然后使用休眠模式 [英] Placing an image in an object, sending the object over rpc and then using hibernate

查看:155
本文介绍了将图像放置在对象中,通过rpc发送对象,然后使用休眠模式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用gwt rpc并在后端休眠.我有一个对象,其中一个字段是图像.我必须将图像放在对象中,通过rpc发送文件,然后使用休眠将其保存回数据库.

I am using gwt rpc and hibernate on the back end. I have an object in which one of the field is an image. I have to place the image in the object, send the file over rpc and saving it back to database using hibernate.

你们中的任何人有这个想法吗?

Does anyone of you have an idea about this??

推荐答案

它不能完全按照描述进行.在javascript中,您无法将文件的二进制内容捕获到javascript VM中.您必须使用文件上传将其发送到服务器.您的流程需要像这样:

It can't be done exactly as described. In javascript, you can't capture the binary contents of a file into the javascript VM. You have to use file upload to send it to the server. Your flow needs to be something like:

  1. 将非二进制字段(文本)捕获到POJO中. IE.表格.
  2. 使用GWT RPC将对象传输到服务器.
  3. 将图像上传到服务器.
  4. 将图像加入服务器上的POJO中.
  5. 保存到数据库.

图片字段必须在@GwtTransient中进行注释,以便在GWT中是瞬态的,而不是在ajax请求中传输,但仍保持休眠状态.

The image field needs to be annotated @GwtTransient to be transient in GWT, not transferred in the ajax requests, but still persisted by hibernate.

这篇关于将图像放置在对象中,通过rpc发送对象,然后使用休眠模式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆