显示pdf格式的图片
<form action="Xmb/Xmb_execute.action" method="get">
<table width="1175px" border="1" cellspacing="0" align="center" style="TABLE-LAYOUT: fixed" cellpadding="0">
<tr>
<td colspan="17" style="border: 1px solid #73C2FF;">
<span style="font-family: '楷体'; font-size: 30px">项目列表</span>
</td>
</tr>
<tr>
<td colspan="2" align="center">项目名称</td>
<td colspan="6" align="center"><input type="text" value="${aa}" name="aa" style="border: 1px solid #73C2FF; font-family: 宋体; font-size: 16px; width: 100%"/></td>
<td colspan="2" align="center">单位名称</td>
<td colspan="5" ><input type="text" value="${bb}" name="bb" style="border: 1px solid #73C2FF; font-family: 宋体; font-size: 16px; width: 100%"/></td>
<td colspan="2"><input type="submit" style="border: 1px solid #73C2FF; font-family: 宋体; font-size: 16px; width: 100%" value="查找" /></td>
</tr>
<tr>
<td colspan="4" align="center"style="border: 1px solid #73C2FF; font-family: 宋体; font-size: 19px;">项目总数</td>
<td colspan="2" align="center"style="border: 1px solid #73C2FF; font-family: 宋体; font-size: 19px;">${count}</td>
<td colspan="4" align="center"style="border: 1px solid #73C2FF; font-family: 宋体; font-size: 19px;">总经费</td>
<td colspan="3" align="center"style="border: 1px solid #73C2FF; font-family: 宋体; font-size: 19px;">${zjf}</td>
<td colspan="2" align="center"style="border: 1px solid #73C2FF; font-family: 宋体; font-size: 19px;">省拨经费</td>
<td colspan="2" align="center"style="border: 1px solid #73C2FF; font-family: 宋体; font-size: 19px;">${sbjf}</td>
</tr>
<tr>
<td rowspan="2" align="center"style="border: 1px solid #73C2FF; font-family: 宋体; font-size: 19px;" colspan="1">序号</td>
<td rowspan="2" align="center"style="border: 1px solid #73C2FF; font-family: 宋体; font-size: 19px;" colspan="8">项目名称</td>
<td rowspan="2" align="center"style="border: 1px solid #73C2FF; font-family: 宋体; font-size: 19px;"colspan="5">单位名称</td>
<td rowspan="2" align="center"style="border: 1px solid #73C2FF; font-family: 宋体; font-size: 19px;" colspan="1">负责人</td>
<td colspan="2" align="center"style="border: 1px solid #73C2FF; font-family: 宋体; font-size: 19px;">经费(万元)</td>
</tr>
<tr>
<td align="center"style="border: 1px solid #73C2FF; font-family: 宋体; font-size: 19px;">合计</td>
<td align="center"style="border: 1px solid #73C2FF; font-family: 宋体; font-size: 19px;">专项</td>
</tr>
<c:forEach items="${xmmb}" var="xmlbs" varStatus="i">
<tr>
<td align="center"style="border: 1px solid #73C2FF; font-family: 宋体; font-size: 19px;" colspan="1">${i.index+1}</td>
//点击项目名称链接pdf
<td align="center"style="border: 1px solid #73C2FF; font-family: 宋体; font-size: 19px;cursor:pointer;" onmouseover="this.style.background='#87CEFA'" onmouseout="this.style.background=''" colspan="8" onclick="f(${xmlbs.id})">${xmlbs.xmmc}</td>
<td align="center"style="border: 1px solid #73C2FF; font-family: 宋体; font-size: 19px;" colspan="5">${xmlbs.dwmc}</td>
<td align="center"style="border: 1px solid #73C2FF; font-family: 宋体; font-size: 19px;" colspan="1">${xmlbs.fzr}</td>
<td align="center"style="border: 1px solid #73C2FF; font-family: 宋体; font-size: 19px;" colspan="1">${xmlbs.jfzj}</td>
<td align="center"style="border: 1px solid #73C2FF; font-family: 宋体; font-size: 19px;" colspan="1">${xmlbs.zxjf}</td>
</tr>
</c:forEach>
</table>
</form>
<table width="1175px" border="1" cellspacing="0" align="center" style="TABLE-LAYOUT: fixed" cellpadding="0">
<tr>
<td colspan="17" align="center"style="border: 1px solid #73C2FF; font-family: 宋体; font-size: 19px;">总共查询到${totalRecord}条记录,每页显示${pageSize}条,共${totalPage}页,当前是第${pageIndex}页。
<%
if( request.getAttribute("pageIndex")!=null){
Integer iPageIndex = (Integer) request.getAttribute("pageIndex");
if( request.getAttribute("totalPage")!=null){
Integer iTotalPage = (Integer) request.getAttribute("totalPage");
if (iPageIndex > 1) {
%> <a
href="<%=request.getContextPath()%>/Xmb/Xmb_execute.action?pageIndex=1&pageSize=${pageSize}&aa=${aa}&bb=${bb}">第一页</a>
<a
href="<%=request.getContextPath()%>/Xmb/Xmb_execute.action?pageIndex=${pageIndex - 1}&pageSize=${pageSize}&aa=${aa}&bb=${bb}">上一页</a>
<%
}
if (iPageIndex < iTotalPage) {
%> <a
href="<%=request.getContextPath()%>/Xmb/Xmb_execute.action?pageIndex=${pageIndex + 1}&pageSize=${pageSize}&aa=${aa}&bb=${bb}">下一页</a>
<a
href="<%=request.getContextPath()%>/Xmb/Xmb_execute.action?pageIndex=${totalPage}&pageSize=${pageSize}&aa=${aa}&bb=${bb}">最后一页</a>
<%
}
}
}
%>
<form id="frmGoPage" name="frmGoPage" method="post"
action="<%=request.getContextPath()%>/Xmb/Xmb_execute.action?pageSize=${pageSize}&aa=${aa}&bb=${bb}">
第 <input name="pageIndex" type="text" id="pageIndex"
style="height: 25px; width: 40px;" value="${pageIndex}" /> 页
<input type="submit" style="height: 25px;" value="Go" />
</form>
</td>
</tr>
</table>
</body>
<script type="text/javascript">
function f(a)
{
var diag = new Dialog();
diag.Width = 300;
diag.Height = 50;
diag.URL = "<%=basePath%>xmlb/test.html";
diag.Title = "选择";
//diag.OKEvent = function(){
//$id('laa').value = diag.innerFrame.contentWindow.document.getElementById('a').value;
//$id('lab').value = diag.innerFrame.contentWindow.document.getElementById('b').value;
//$id('lac').value = diag.innerFrame.contentWindow.document.getElementById('c').value;
//$id('lad').value = diag.innerFrame.contentWindow.document.getElementById('d').value;
//$id('lae').value = diag.innerFrame.contentWindow.document.getElementById('e').value;
//save();
//};//点击确定后调用的方法
diag.OnLoad=function(){
if (window.addEventListener) {
//其它浏览器的事件代码: Mozilla, Netscape, Firefox
//添加的事件的顺序即执行顺序 //注意用 addEventListener 添加带on的事件,不用加on
diag.innerFrame.contentWindow.document.getElementById('e').value=a;
}
else {
//IE 的事件代码 在原先事件上添加 add 方法
diag.innerFrame.contentWindow.document.getElementById('b').addEventListener('blur', function(){checkNum(this);} , false);
}
};
diag.show();
var doc=diag.innerFrame.contentWindow.document;
doc.open();
doc.write("<table style=' cellpadding='0' align='center' cellspacing='0' border='0' width='100%' >"+
"<tr>"+
"<td align='center' width='100px' rowspan='2' style=' font-family: 宋体; font-size: 19px;'><input type='hidden' id='e' />"+
"<button onclick='showys()'"+
"style=\"width: 100px; height: 30px; font-family: 宋体; font-size: 19px; border: none; color: white; \">"+
"项目预算"+
"</button>"+
"</td>"+
"</tr>"+
"<tr>"+
"<td align='center' width='100px' rowspan='2' style=' font-family: 宋体; font-size: 19px;'>"+
"<button onclick='showfa()'"+
"style=\"width: 100px; height: 30px; font-family: 宋体; font-size: 19px; border: none; color: white; background-color: #0099cc;\">"+
"实施方案"+
"</button>"+
"</td>"+
"</tr>"+
"</table>"+
"<script type=\"text/javascript\">"+
"function showys(){"+
"var dd=document.getElementById('e').value;"+
"var url='Xmb/Xmb_downFileys.action?dwid='+dd;"+
"window.open (url, 'ys', 'height=768, width=1100, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, status=no');"+
"}"+
"function showfa(val){"+
"var dd=document.getElementById('e').value;"+
"var url='Xmb/Xmb_downFilefa.action?dwid='+dd;"+
"window.open (url, 'fa', 'height=768, width=1100, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, status=no');"+
"}"+
"<\/script>") ;
doc.close();
}
</script>
</html>
//action里面的方法
public String downFileys()throws Exception{
//实体类
Xmxxdz xmxx=new Xmxxdz();
//根据id查找
xmxx=xmxxdzDao.getUrl(dwid);
ActionContext ctx = ActionContext.getContext();
HttpServletResponse response = (HttpServletResponse) ctx
.get("com.opensymphony.xwork2.dispatcher.HttpServletResponse");
// 文件的默认保存名
// 读到流中
InputStream inStream = new FileInputStream(xmxx.getUrla());// 文件的存放路径
// 设置输出的格式
response.reset();
response.setContentType("application");
response.addHeader("Content-Disposition", "inline; filename=" + xmxx.getUnid()+".pdf");
// 循环取出流中的数据
byte[] b = new byte[16*1024];
int len;
try {
while ((len = inStream.read(b)) > 0)
{
response.getOutputStream().write(b, 0, len);
}
response.getOutputStream().flush();
inStream.close();
response.getOutputStream().close();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
public String downFilefa()throws Exception{
Xmxxdz xmxx=new Xmxxdz();
xmxx=xmxxdzDao.getUrl(dwid);
ActionContext ctx = ActionContext.getContext();
HttpServletResponse response = (HttpServletResponse) ctx
.get("com.opensymphony.xwork2.dispatcher.HttpServletResponse");
// 文件的默认保存名
// 读到流中
InputStream inStream = new FileInputStream(xmxx.getUrlb());// 文件的存放路径
// 设置输出的格式
response.reset();
//response.setHeader("Content-Type", "application/vnd.ms-word");
response.setContentType("application");
response.addHeader("Content-Disposition", "inline; filename=" + xmxx.getUnid()+".pdf");
byte[] b = new byte[16*1024];
int len;
try {
while ((len = inStream.read(b)) > 0)
{
response.getOutputStream().write(b, 0, len);
}
response.getOutputStream().flush();
inStream.close();
response.getOutputStream().close();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}