oracle保存blob图片
2018-06-18 03:54:44来源:未知 阅读 ()
1、新建的表结构为
2、hbm.xml文件为AuthSfzDO.hbm.xml
<?xml version="1.0" encoding="UTF-8"?> <!-- Hibernate XML Mapping File --> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd"> <hibernate-mapping package="com.wisoft.tysfrz.entity" auto-import="true"> <class name="AuthSfzDO" table="Auth_sfz"> <id name="id"> <column name="id" not-null="true" length="32"/> <generator class="uuid.hex"> </generator> </id> <property name="zmsfzname" lazy="false"> <column name="zmsfzname" length="100"/> </property> <property name="zmsfzdata" lazy="false"> <column name="zmsfzdata"/> </property> <property name="fmsfzname" lazy="false"> <column name="fmsfzname" length="100"/> </property> <property name="fmsfzdata" lazy="false"> <column name="fmsfzdata"/> </property> <property name="scsfzname" lazy="false"> <column name="scsfzname" length="100"/> </property> <property name="scsfzdata" lazy="false"> <column name="scsfzdata"/> </property> <property name="grinfoid" lazy="false"> <column name="grinfoid" length="32"/> </property> <property name="uptime" lazy="false"> <column name="uptime" length="20"/> </property> </class> </hibernate-mapping>
3、Java类为AuthSfzDO.java
package com.wisoft.tysfrz.entity; import java.io.Serializable; /** * 身份证信息表 * */ public class AuthSfzDO implements Serializable{ /** * */ private static final long serialVersionUID = -6153078643179583844L; /** * 主键ID */ private String id; /** * 正面身份证照片 */ private String zmsfzname; /** * 反面身份证照片 */ private String fmsfzname; /** * 手持身份证照片 */ private String scsfzname; /** * 个人信息ID */ private String grinfoid; /** * 更新时间 */ private String uptime; /** * 正面身份证照片 */ private byte[] zmsfzdata; /** * 反面身份证照片 */ private byte[] fmsfzdata; /** * 手持身份证照片 */ private byte[] scsfzdata; public String getId() { return id; } public void setId(String id) { this.id = id; } public String getZmsfzname() { return zmsfzname; } public void setZmsfzname(String zmsfzname) { this.zmsfzname = zmsfzname; } public String getFmsfzname() { return fmsfzname; } public void setFmsfzname(String fmsfzname) { this.fmsfzname = fmsfzname; } public String getScsfzname() { return scsfzname; } public void setScsfzname(String scsfzname) { this.scsfzname = scsfzname; } public String getGrinfoid() { return grinfoid; } public void setGrinfoid(String grinfoid) { this.grinfoid = grinfoid; } public String getUptime() { return uptime; } public void setUptime(String uptime) { this.uptime = uptime; } public byte[] getZmsfzdata() { return zmsfzdata; } public void setZmsfzdata(byte[] zmsfzdata) { this.zmsfzdata = zmsfzdata; } public byte[] getFmsfzdata() { return fmsfzdata; } public void setFmsfzdata(byte[] fmsfzdata) { this.fmsfzdata = fmsfzdata; } public byte[] getScsfzdata() { return scsfzdata; } public void setScsfzdata(byte[] scsfzdata) { this.scsfzdata = scsfzdata; } }
4、controller层
@RequestMapping("/uploadZmsfzImg") @ResponseBody public AjaxResult uploadZmsfzImg(HttpServletRequest request, MultipartFile file, String id) throws Exception{ AjaxResult result = new AjaxResult(false); //保存 try { // file.transferTo(targetFile); result.setMsg("上传成功!"); result.setSuccess(true); // result.setData(fileName); AuthSfzDO authSfzDO = new AuthSfzDO(); // authSfzDO.setZmsfzname(fileName); authSfzDO.setGrinfoid(id); authSfzDO.setZmsfzdata(zmsfzData); tysfrzUserBO.uploadSfzInfo(authSfzDO); } catch (Exception e) { e.printStackTrace(); result.setMsg("上传图片失败!"); log.error(this, e); } return result; }
5、dao层
public void saveOrUpdateSfzInfo(AuthSfzDO authSfzDO){ List<AuthSfzDO> list = findAuthSfzInfoBygrid(authSfzDO.getGrinfoid()); String uptime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date(System.currentTimeMillis())); authSfzDO.setUptime(uptime); if (list !=null && list.size() > 0) { StringBuffer hql = new StringBuffer() ; List<Object> params = new ArrayList<>(); if (authSfzDO.getZmsfzdata() != null) { hql.append("update AuthSfzDO set zmsfzdata = ?") ; params.add(authSfzDO.getZmsfzdata()); } if (authSfzDO.getFmsfzdata() != null) { hql.append("update AuthSfzDO set fmsfzdata = ? ") ; params.add(authSfzDO.getFmsfzdata()); } if (authSfzDO.getScsfzdata() != null) { hql.append("update AuthSfzDO set scsfzdata = ?") ; params.add(authSfzDO.getScsfzdata()); } hql.append(" ,uptime = ? "); params.add(uptime); hql.append(" where grinfoid = ? "); params.add(authSfzDO.getGrinfoid()); this.updateByHql(hql.toString(), params.toArray()); }else{ this.save(authSfzDO); } }
6、前台页面
<script type="text/javascript" src="${basePath}r/project/nfm/plupload/plupload.full.min.js" ></script>
<button class="btn" id="uploadSfz_zm" data-type="uploadIms" style="width:130px;">上传正面身份证</button>
uploadZmsfzImg(); function uploadZmsfzImg() { var uploaderImg = new plupload.Uploader({ browse_button: 'uploadSfz_zm', url: GLOBAL.basePath + 'usercenter/uploadZmsfzImg.json?id='+$('#queryflag').val(), flash_swf_url: GLOBAL.basePath + 'r/project/nfm/plupload/Moxie.swf', silverlight_xap_url: GLOBAL.basePath + 'r/project/nfm/plupload/Moxie.xap', multi_selection: false, filters : { max_file_size : '20mb', mime_types: [ {title : "图片文件(jpg,jpeg,gif,png)",extensions : "jpg,jpeg,gif,png"} ] }, init: { PostInit: function() {}, BeforeUpload:function(up,file){ //uploader.setOption("headers",{"CSRFToken":$("meta[name='_csrf']").attr("content")}); }, FilesAdded: function(up, files) { uploaderImg.start(); //开始上传 }, UploadProgress: function(up, file) {}, FileUploaded: function(up, file, data) { data = JSON.parse(data.response); if (data.success) { $.showMsg("上传成功", function() { sfzflag1 = true; var name = data.data; var html = '<img alt="" src="../../usercenter/getZmSfzImages.do?grinfoid='+$('#queryflag').val()+'" style="cursor: pointer;width: 160px;height: 90px;">'; $("#sfz-zm").html(html); }); } else { $.showMsg("上传失败"); } $.hideLoading(); }, Error: function(up, err) { err = JSON.parse(err.response); alert(err.msg); card1Falg=false; } } }); uploaderImg.init(); }
标签:
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有
上一篇:java内存模型
下一篇:Java——Spring注解
- Oracle SQLPlus导出数据到csv文件 2020-05-18
- Oracle用decode函数或CASE-WHEN实现自定义排序 2020-05-18
- 你知道如何自动保存 Spring Boot 应用进程号吗 2020-04-20
- MyBatis+Oracle在执行insert时空值报错之从源码寻找解决办法 2020-04-15
- Mybatis+Oracle搭配insert空值报错之myBatis+mysql驱动+orac 2020-04-14
IDC资讯: 主机资讯 注册资讯 托管资讯 vps资讯 网站建设
网站运营: 建站经验 策划盈利 搜索优化 网站推广 免费资源
网络编程: Asp.Net编程 Asp编程 Php编程 Xml编程 Access Mssql Mysql 其它
服务器技术: Web服务器 Ftp服务器 Mail服务器 Dns服务器 安全防护
软件技巧: 其它软件 Word Excel Powerpoint Ghost Vista QQ空间 QQ FlashGet 迅雷
网页制作: FrontPages Dreamweaver Javascript css photoshop fireworks Flash