JSP实现从数据库导出数据到超过下载的方法
本文实例讲述了JSP实现从数据库导出数据到超过下载的方法。分享给大家供大家参考,具体如下:
关键代码:
% @页内容类型='应用程序/ms excel % %//响应。setheader(' Content-disposition ',' inlinefilename=videos。xls’);回应。setheader(' Content-disposition ',' attachmentfilename=test。xls’);//以上这行设定传送到前端浏览器时的档名为test.xls //就是靠这一行,让前端浏览器以为接收到一个超过档%简单测试例子:
“% @”页面语言=“Java”导入=“Java”。乌提尔。*,Java。io。* "页面编码=' GBK ' % % @页面内容类型='应用程序/ms excel ' %//响应。setheader(' Content-disposition ',' inlinefilename=videos。xls’);回应。setheader(' Content-disposition ',' attachmentfilename=test。xls’);//以上这行设定传送到前端浏览器时的档名为test.xls //就是靠这一行,让前端浏览器以为接收到一个超过档% %@页面导入=' org。弹簧框架。网络。语境。web application context“% @”页面导入=' com。测试。* % % @页面导入=' org。弹簧框架。网络。语境。支持。webapplicationcontextutils“% % String path=request”。getcontextpath();字符串基本路径=请求。getscheme()' ://'请求。getservername()“:”请求。getserverport()“path ”/;% % WebApplicationContext CTX=webapplicationcontextutils。getwebapplicationcontext(这。getservletcontext());用户经理um=(用户经理)CTX。GetBean('用户管理器');% !DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN ' HTML head base href=' %=base path % ' title spring JDBC测试/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='关键字' content='关键字1,关键字3 ' meta http - link rel='样式表type=' text/CSS ' href=' style。CSS '-/头体br表格边框=' 1 ' width=' 100% ' tr tdid/TD tdname/TD/tr % list用户用户用户2=um。get user list();for(int I=0;iusers 2。size();I){ int t _ id2=用户2。得到(我).getId();字符串t _ name 2=用户2。得到(我).getName();% tr TD %=t _ id2 %/TD TD TD %=t _ name 2%/TD/tr % } %/表格/正文/html
希望本文所述对大家JSP程序设计有所帮助。
版权声明:JSP实现从数据库导出数据到超过下载的方法是由宝哥软件园云端程序自动收集整理而来。如果本文侵犯了你的权益,请联系本站底部QQ或者邮箱删除。