日期:2014-05-18 浏览次数:20833 次
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String adname=request.getParameter("adname");
ApplicationContext App=WebApplicationContextUtils.getWebApplicationContext(request.getSession().getServletContext());
AdDao adDao=(AdDao)App.getBean("adDao");
Ad ad=adDao.findAd(adname);
byte images[]=ad.getAdimage();
response.setContentType("image/jpeg");
InputStream in=new ByteArrayInputStream(images);
OutputStream toClient=response.getOutputStream();
int len;
byte[] buf=new byte[1024];
while((len =in.read(buf,0,1024))!=-1){
toClient.write(buf,0,len);
}
toClient.close();