现在的位置: 首页 > 综合 > 正文

struts显示图片的Action

2013年06月13日 ⁄ 综合 ⁄ 共 499字 ⁄ 字号 评论关闭

public class ProjectShowPictAction extends Action {

 public ActionForward execute(ActionMapping mapping, ActionForm actionform,
   HttpServletRequest request, HttpServletResponse response) throws Exception {
  String id=request.getParameter("id");
   byte[] photo=null;
   ProjectDao pd=new ProjectDao();
   if(id!=null&&!"".equals(id)){
    photo=pd.queryPhoto(id);
    if(photo!=null){
     response.setContentType("image/*");
    response.getOutputStream().write(photo);
    response.getOutputStream().close();
    }
   }
 return null;
 }

抱歉!评论已关闭.