img.jsp

来自「管理公司合同」· JSP 代码 · 共 41 行

JSP
41
字号
<%@ page import="cn.com.juneng.system.common.COMMON"%>
<%@ page import="java.io.File"%>
<%@ page import="org.springframework.util.FileCopyUtils"%>
<%
response.setHeader("Pragma","No-cache");
response.setContentType("image/gif");
cn.com.juneng.baseinfo.vo.BaseinfoVOImpl vo = null;
try{
	cn.com.juneng.baseinfo.service.BaseinfoService service = (cn.com.juneng.baseinfo.service.BaseinfoService)cn.com.juneng.system.common.SpringBeanFactory.getBean("baseinfoService");
	String  ryid=request.getParameter("rid");
	byte[] xp =null;
	if(!COMMON.isEmpty(ryid)){
	  vo=service.findByPrimaryKey(ryid);
	  if(!COMMON.isEmpty(vo.getXp())){
		  xp= vo.getXp();
		  
	    }else {
	     
	      File file=new File(request.getRealPath("/")+"no_pic.gif");
	      java.io.FileInputStream inputstr=new java.io.FileInputStream(file);
	      java.io.ByteArrayOutputStream   bos   =   new   java.io.ByteArrayOutputStream();  
		  int   ch;  
		  while((ch=inputstr.read())!=-1)   {  
		          bos.write(ch);  
		  }  
		  inputstr.close();  
		  xp  =   bos.toByteArray();  
		  bos.close();   	      
		  
	    }
	    //测试重新写文件
	    //File againfile=new File("c:/dd.gif");
	    //FileCopyUtils.copy(xp,againfile);
	    response.getOutputStream().write(xp);
	    response.getOutputStream().flush();
	    
	  }
}catch(Exception e){
	 e.printStackTrace();
}
%>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?