0
我希望查看PDF文件只是在使用java.while彈出窗口中動態查看我點擊該文件鏈接打開PDF文件彈出窗口其不允許下載加載選項請幫我給在java.i一些示例需要需要Java代碼用行動把jsp如何在jsp中查看pdf文件
File f= new File(file);
if(f.exists()){
ServletOutputStream op= response.getOutputStream();
response.reset();
if(check==1){
response.setContentType("application/pdf");
}else{
response.setContentType(content);
}
// response.setHeader("Content-disposition","attachment; filename=" +fileName);
byte[] buf = new byte[4096];
int length;
DataInputStream in = new DataInputStream(new FileInputStream(f));
while ((in != null) && ((length = in.read(buf)) != -1)){
op.write(buf,0,length);
}
in.close();
op.flush();
op.close();
}
你想在瀏覽器中打開pdf文檔還是要在框架中顯示它? –