亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

JSP 導出Excel表格的實例

 更新時間:2017年06月19日 08:03:37   投稿:jingxian  
下面小編就為大家?guī)硪黄狫SP 導出Excel表格的實例。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧

java 后臺返回一個ModelAndView 對象,然后加入這2行設(shè)置

response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-disposition","attachment;filename=" + URLEncoder.encode("會員列表.xls", "UTF-8"));

也可以把這二行設(shè)置放入JSP中

在jsp代碼如下:

<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
 response.setContentType("application/vnd.ms-excel");
 response.setHeader("Content-disposition","attachment;filename=" + java.net.URLEncoder.encode("會員列表.xls", "UTF-8"));
%>
<!DOCTYPE html>
<html>
<head>
 <title>CMS-會員管理</title>
 <meta charset="utf-8" />
 <meta http-equiv="pragma" content="no-cache"/>
 <meta http-equiv="cache-control" content="no-cache"/>
 <meta http-equiv="expires" content="0"/>
</head>
<body>

<table id="sample-table-1" border="1" cellpadding="2" cellspacing="1">
 <thead>
 <tr>
  <th nowrap width="15%">序號</th>
  <th nowrap width="5%">卡號</th>
  <th nowrap width="5%">姓名</th>
  <th nowrap width="5%">年齡</th>

 </tr>
 </thead>
 <tbody>
 <c:forEach items="${list}" var="model" varStatus="status" >
  <tr>
   <td>${model.id}</td>
   <td>${model.cardNo}</td>
   <td>${model.name}</td>
   <td>${model.age}</td>
  </tr>
 </c:forEach>
 </tbody>
</table>
</body>
</html>

以上這篇JSP 導出Excel表格的實例就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論