(1).框架为SSH:
xml配置:(blank.jsp页面是啥都没有,完全一个空白页面)
/blank.jsp
JAVA后台:
public String showPdf() throws IOException{
FileData fileData = fileDataService.getById(id);
byte[] bit = fileData.getData();
if(bit != null){
HttpServletResponse response = ServletActionContext.getResponse();
response.setContentLength(bit.length);
response.setContentType("application/pdf;charset=UTF-8");
OutputStream test = response.getOutputStream();
DataOutput output = new DataOutputStream(test);
for( int i = 0; i < bit.length; i++ ) {
output.writeByte(bit[i] );
}
test.flush();
test.close();
test=null;
response.flushBuffer();
}
return ActionSupport.SUCCESS;
}
JSP页面请求:
./iface/showPdf?id="