下载链接选项无法在显示标记中使用

时间:2013-11-28 10:27:34

标签: jsp displaytag

HiI我正在使用displat标签库显示表它工作正常但是当我来导出链接时它会给你带来麻烦所以可以帮忙怎么做这个 我的代码就像这样

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ page import = "com.preva.vo.StoppageDetails"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib uri="http://displaytag.sf.net" prefix="display" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="css/displaytag.css" type="text/css">  
<link rel="stylesheet" href="css/screen.css" type="text/css">  
<link rel="stylesheet" href="css/site.css" type="text/css">  
<link href="css/sty.css" rel="stylesheet" type="text/css" />
<link href="css/tabborder.css" rel="stylesheet" type="text/css" />
</head>
<body>
<jsp:include page="Header.jsp" />
    <c:choose>
    <c:when test="${not empty trackingdetails}"> 
            <table id="display_table">
            <tr ><td style="text-align:center;"><b>Tracking Details</b></td></tr>
            <tr ><td style="text-align:center;"><b><%=request.getParameter("vehicleId") %></b></td></tr>
            <tr><td style="text-align:center;"> From &nbsp;<%=session.getAttribute("fromdate") %>&nbsp;to&nbsp;<%=session.getAttribute("startdate") %></td></tr>
            </table>
     <display:table id="deviceDetailsID" name="sessionScope.trackingdetails" pagesize="10" export="true" sort="list">
     <display:setProperty name="basic.empty.showtable" value="true" />
     <display:setProperty name="paging.banner.group_size" value="10" />
     <display:setProperty name="paging.banner.item_name" value="Record" />
     <display:setProperty name="paging.banner.item_names" value="Records" />

    <display:column property="serialID" title="Sl No" style="width: 3%"/>
    <display:column property="deviceID" title="DeviceID" style="width: 1%"/>
    <display:column property="datestamp" title="DATE" format="{0,date,dd-MM-yyyy}"/>
    <display:column property="timestamp" title="TIME" />
    <display:column property="speed" title="Speed"  />
    <display:column property="statuscode" title="Status Code"/>
    <display:column property="address" title="Address"  />
</display:table> 
</c:when>
<c:otherwise>
<jsp:include page="Pages/Trackingbody.jsp"/>
<div id="MenuLineDiv" style="width:100%; height: 2px; font-size: 2px; background-color: #FFCD44; position: relative; top: 0px;"></div>
<table width="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="#FFFFFF">
    <tr class="topheader">
        <td colspan="6" style="color:white;text-align:center;">Tracking report for <%=request.getParameter("vehicleId") %> from <%=session.getAttribute("fromdate") %> to <%=session.getAttribute("startdate") %> </td>
    </tr>


    <tr class="secondhedr">
        <td colspan="6" style="color:white;text-align:center;">No data found</td>
    </tr>

</table>
  </c:otherwise>
</c:choose> 
    <jsp:include page="Footer.jsp"/>        
</body>

</html>

当我点击导出'csv'时它在浏览器中显示不是一个文件,即它不是要求我保存或打开文件选项可以任何帮助 提前致谢

1 个答案:

答案 0 :(得分:0)

之后的代码中
<display:setProperty name="paging.banner.item_names" value="Records" />

行添加两个属性

<display:setProperty name="export.pdf" value="true" /> //set false if you don't want
<display:setProperty name="export.csv" value="true" /> //set false if you don't want

现在,再添加两个属性来设置下载文件名

<display:setProperty name="export.csv.filename" value="CSV Report.pdf"/>
<display:setProperty name="export.pdf.filename" value="PDF Report.pdf"/>