比较简洁的下载代码

使用ServletContext

public void doGet(HttpServletRequest request,HttpServletRespone response){
     response.setcontentType("application/jar");
     
     ServletContext ctx=getServletContext();
     InputStream is = ctx.getResourceAsStream("/aa.jar");
     
     int read=0;
     byte[] bytes = new byte[1024];
     OutputStream os = response.getOutputStream();
     while((read=is.read(bytes))!=-1){
           os.write(bytes,0,read);

      }
} 
 

你可能感兴趣的:(OS)