国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JSP > 正文

JSP實現(xiàn)從數(shù)據(jù)庫導(dǎo)出數(shù)據(jù)到Excel下載的方法

2020-07-27 21:29:24
字體:
供稿:網(wǎng)友

本文實例講述了JSP實現(xiàn)從數(shù)據(jù)庫導(dǎo)出數(shù)據(jù)到Excel下載的方法。分享給大家供大家參考,具體如下:

關(guān)鍵代碼:

<%@ page contentType="application/msexcel" %><%  //response.setHeader("Content-disposition","inline; filename=videos.xls");  response.setHeader("Content-disposition","attachment; filename=test.xls");  //以上這行設(shè)定傳送到前端瀏覽器時的檔名為test.xls  //就是靠這一行,讓前端瀏覽器以為接收到一個excel檔 %>

簡單測試?yán)樱?/p>

<%@ page language="java" import="java.util.*,java.io.*" pageEncoding="GBK"%> <%@ page contentType="application/msexcel" %> <%   //response.setHeader("Content-disposition","inline; filename=videos.xls");   response.setHeader("Content-disposition","attachment; filename=test.xls");   //以上這行設(shè)定傳送到前端瀏覽器時的檔名為test.xls   //就是靠這一行,讓前端瀏覽器以為接收到一個excel檔  %> <%@ page import="org.springframework.web.context.WebApplicationContext"%> <%@ page import="com.test.*"%> <%@ page import="org.springframework.web.context.support.WebApplicationContextUtils"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <% WebApplicationContext ctx = WebApplicationContextUtils.getWebApplicationContext(this.getServletContext()); UserManager um = (UserManager) ctx.getBean("userManager");  %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html>  <head>   <base href="<%=basePath%>">   <title>spring jdbc test</title>   <meta http-equiv="pragma" content="no-cache">   <meta http-equiv="cache-control" content="no-cache">   <meta http-equiv="expires" content="0">     <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">   <meta http-equiv="description" content="This is my page">   <!--   <link rel="stylesheet" type="text/css" href="styles.css">   -->  </head>  <body> <br> <table border="1" width="100%"> <tr> <td>id</td> <td>name</td>   </tr> <%     List<User> users2=um.getUserList();     for(int i=0;i<users2.size();i++)     {       int t_id2=users2.get(i).getId();       String t_name2=users2.get(i).getName();       %>       <tr>    <td><%=t_id2 %></td> <td><%=t_name2 %></td>   </tr>       <%     }  %> </table>  </body> </html> 

希望本文所述對大家JSP程序設(shè)計有所幫助。

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 洪洞县| 紫金县| 长治市| 灵璧县| 衡水市| 盐城市| 蓬安县| 吉木乃县| 新巴尔虎右旗| 藁城市| 桂平市| 土默特左旗| 长治市| 巩义市| 永宁县| 惠州市| 陵水| 二连浩特市| 奉节县| 津南区| 齐齐哈尔市| 成都市| 内黄县| 博兴县| 和硕县| 九江市| 施秉县| 乌苏市| 满洲里市| 滦南县| 青州市| 阿鲁科尔沁旗| 浦北县| 义乌市| 林口县| 卫辉市| 高清| 宁强县| 武夷山市| 本溪市| 呼和浩特市|