1.MyEclipse反向工程后得到image的对应的类型竟然是String,要把它改成byte[]
private byte[] avatar;
2.在XX.hbm.xml配置文件中,相应字段改为binary
<property name="avatar" type="binary">
<column name="avatar" />
</property>
3.直接在网页上显示
在服务器端将实体类转换为json数据返回给
在网页上用内容拼接到img标签的src属性中
$.getJSON("${ctx}/query/monitor/ajaxEmployee.do?code="+employeeCode,function(data){
if(data != null){
$("#"+counterCode).find(".employee_code").text(data.id.code).end()
.find(".employee_name").text(data.name).end()
.find(".employee_jobTitle").text(data.jobTitle).end()
.find(".employee_head").attr("src","data:image/jpg;base64,"+data.avatar);
}
});