头像上传方法修改成如下才可以,是不是nutz book里写错了?
@Ok("raw:jpg")
@At("/avatar")
@GET
public Object readAvatar(@Attr(scope=Scope.SESSION, value="me")int userId, HttpServletRequest req) throws SQLException {
UserProfile profile = Daos.ext(dao, FieldFilter.create(UserProfile.class, "^avatar$")).fetch(UserProfile.class, userId);
if (profile == null || profile.getAvatar() == null) {
return new File(req.getSession().getServletContext().getRealPath("/rs/user_avatar/none.jpg"));
}
return profile.getAvatar().getBinaryStream();
}
问答
【nutz book]【头像上传方法】req.getServletContext().getRealPath("/rs/user_avatar/none.jpg")报错
标签:
无
添加回复
请先登陆