前端
<div style="border:2px solid red" >
<img alt="证件" src="${base}/zjinfo/profile/avatar">
</div>
<form action="${base}/zjinfo/profile/avatar" method="post" enctype="multipart/form-data">
<input type="file" name="file">
<button type="submit">更新</button>
</form>
后端
public Object readAvatar(@Attr(scope=Scope.SESSION, value="me")String cxqqdh, HttpServletRequest req) throws SQLException {
System.out.println("cxqqdh:"+cxqqdh);
// OutputStream out = resp.getOutputStream();
Zjinfo zjinfo = Daos.ext(dao, FieldFilter.create(Zjinfo.class, "^gzz$")).fetch(Zjinfo.class, Cnd.where("cxqqdh", "=", cxqqdh).and("xh", "=", "1"));
// BufferedImage img = Images.read(new ByteArrayInputStream(buf));
byte[] b1 = null;
if (zjinfo == null || zjinfo.getGzz()== null) {
return new File(req.getServletContext().getRealPath(""));
}
return new File("C:\\Users\\15522\\Desktop\\sjw\\none.jpg");
}