后台代码:
public void previewFileOnline(){
BufferedInputStream bis = null;
OutputStream os = null;
try {
String path = request("filePath");//网络图片地址
response().setContentType("text/html; charset=UTF-8");
if("pdf".equalsIgnoreCase(request("type"))){
response().setContentType("application/pdf");
}else{
response().setContentType("image/jpeg");
}
URL url =new URL(path);
bis = new BufferedInputStream(url.openStream());
os = response().getOutputStream();
int count = 0;
byte[] buffer = new byte[1024 * 1024];
while ((count =bis.read(buffer)) != -1){
os.write(buffer, 0,count);
}
os.flush();
}catch (Exceptione) {
e.prin