日期:2014-05-17 浏览次数:20684 次
public String getImg()throws Exception{ HttpServletResponse response=null; ServletOutputStream out = null; response=ServletActionContext.getResponse(); response.setContentType( "multipart/form-data" ); out = response.getOutputStream(); //从数据库得到图片存放路径,获取图片转换成流 byte[] picByte=Base64.decode(daoImpl.getBytesFile(new File(ItemVo.getPicturePath()))); try{ out.write(picByte); }catch(Exception e){ e.printStackTrace(); }finally{ if(out!=null){ out.close(); } } return null; }
<action name="Image" class="com.sdjg.struts.action.xxx.WapAction" method="getImg"></action>
<img src="<s:url action="Image"><s:param name="pictureIndex" value="id"></s:param></s:url>">