本文与前文的需求类似,废话不表,开始我们的正文部分吧
准备工作:
a.操作系统 :win7 x64
b.基本软件:MySQL,Mybatis,SQLyog
-------------------------------------------------------------------------------------------------------------------------------------一。插入操作
1.在我们的userinfo数据表中增加一个headpic字段,类型为longblob,如下:

2.我们沿用上文工程,原有内容保持不变,需要修改的地方见下文。
3.在UserInfo中增加属性,如下:
[java] view
plain copy
- @SuppressWarnings("serial")
- public class UserInfo implements Serializable {
- private String userid;
- private String department;
- private String position;
- private String mobile;
- private String gender;
- private String email;
- private byte[] headpic;
- private String cv;
- //其他内容请自行补充。
- }
[html] view
plain copy
- <insert id="insertUserInfoByBlob" parameterType="userInfo">
- insert into userinfo values(#{userid},#{department},#{position},#{mobile},#{gender},#{email},#{headpic},#{cv})
- insert>
5.在UserInfoDao中,增加对应接口:
[java] view
plain copy