jsp生成 文件下载 比如txt

Spring + easyUI(jsp) 导出txt文本文件 之前还在纠结的问题就是,网上找到的资料太简单都不知道是什么,然后自己在公司的框架下成功跑起来一个导出txt文本文件的功能,趁着今天有点时间而且书忘记带,写下来。 当然我的方法也不过只是其中一个的方法,肯定有其他方法,而且我的也不一定通用。仅供学习之用。 首先创建两个关于导入txt文本文件的类,这两个类也是我模仿框架里写了Excel的模块写的。 首先创建类BaseTxtView注意这个类继承S 阅读详情

jsp生成 文件下载 比如txt

http://blog.youkuaiyun.com/zbz0425/article/details/8102124


download.jsp

<%@page import="Java.io.*"%>

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
String filename = request.getParameter("filename");//"tzhsymd.txt";    
String filepath = request.getParameter("filepath");//"路径";    
response.setContentType("application/octet-stream");    
response.setHeader("Content-Disposition","attachment;filename = "+filename);  
BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(filepath+filename),"utf-8"));
BufferedWriter fos =new BufferedWriter(new OutputStreamWriter(response.getOutputStream(),"utf-8"));
String line;
while((line=br.readLine())!=null){
    fos.write(line+"\n\r");
}
fos.flush();
fos.close();
br.close();
out.clear();
out = pageContext.pushBody();
%>   

//out.clear();
//out = pageContext.pushBody();

加上这两个是防止  getOutputStream() has already been called for this response


在点击链接上添加 filename filepath 参数

<a href="./download.jsp?filename=fwscl.txt&filepath=<%=lujing %>" >下载</a>


jsp导出csv文件 使用io流写如文件导出csv文件,使用jsp实现。简单的方法可以推广! 立即下载

相关推荐

java代码自动生成.txt数据文件

java代码自动生成.txt数据文件,java代码自动生成.txt数据文件

java jsp下载txt文件_jsp导出TXT文件

Get get = new Get();HistoryAlarmProcessor hap = new HistoryAlarmProcessor();String cellTypeConfId = request.getParameter("cellTypeConfId");if(cellTypeConfId==null){cellTypeConfId = "";}String cellConf...

weixin_39633171的博客 292

Java下载txt文件

Java实现把字符串下载为txt文件的工具类。

java生成并下载TXT文件

List ml = db.queryMapList2(m_strLoginCityID, sql); //路径   String src = request.getRealPath("log") + "\\text.txt";   if (ml != null) {    File f = new File(src);    BufferedWriter bw = null;    bw =...

hzgzf的博客 1111

jsp页面导出excel

jsp页面导出excel的实现相关代码,是从整个项目中把相关的几个页面拿出来分享一下

jsp点击实现导出数据

我们需要当jsp点击一个导出数据的按钮的时候,弹出一个对话框,实现数据导出;(其实变相的就是一个文件下载).

jsp,html导出Excel文档-----纯js

注意这个方法tableToExcel第一个参数是table表格的id,填写自己定义的table的id就行,后面那个data的参数不管 <button type="button" onclick="tableToExcel('item','data')">导出</button> 导出excel文档的demo <html> <head> <meta http-equiv="content-Type" conte.........

夜空繁星VV 1060

Keil MDK 5.37及之后版本 安装AC5(ARMCC)编译器详细步骤

由于Keil 5.37及之后版本不再默认安装AC5(ARMCC)编译器,这就会导致由AC5编译的工程无法正常编译,往往输出窗口会提示以下信息:*** Target ‘STM32xxxx‘ uses ARM-Compiler ‘Default Compiler Version 5‘ which is not available.

s_Modesto的博客 1万+

jsp 导出内容到 txt 中。

近来,在工作中用到导出内容到 txt 文本中的技术,现在记下来。 %@page contentType="text/html;charset=utf-8"%> %@page language="java" import="java.io.*"%> %@page language="java" import="java.util.*"%>   String exportTxt = (St

zhouqiang2008的专栏 1287

【GPT】Coze使用开放平台接口-【7】Dify 比较篇

coze 用于社交,dify 用来内部构建。抛开工作流,机器人,工具,coze 最大的区别在于可以直接发布到社交媒体上。所以,coze 对操作体验上也花了不少功夫,而 dify 就专注在帮助使用者打磨工作流。coze 各个大模块之前可以联动的机制也比较多,所以侧重点各不相同。

非晓为骁的博客 7615

2023-07-04 Fast-Lio论文中公式(6)与BCH公式中近似雅可比公式的一致性推导

将(1)式代入(6)式,就有。

wmorries的博客 480

如何在jsp页面下载后台服务器返回的数据并保存为txt格式

首先新建一个jsp页面,jsp代码如下 "> My JSP 'download.jsp' starting page <!-- --> $(document).ready(function(){ $('#downloadbtn').cli

mashang666的博客 1727

项目管理——14规划绩效域论文套路

规划绩效域论文套路

Flee Elf 1153

jsp根据数据生成txt下载

//文件名 String fileName = "agent01_011_" + BaseUtil.getDay() + ".txt"; response.setContentType("text/plain;charset=GBK"); response.setHeader("Content-disposition", "attachment; filename=" + fileN

hxt_hn的专栏 368

《最游记》游戏开发全栈指南:从源码解析到实战部署

本文提供了一份详尽的《最游记》游戏源码全栈开发指南。文章深入解析了这款3D玄幻网游的完整源码结构,涵盖客户端、服务端、引擎和工具链,并提供了从环境搭建、核心模块解析到实战修改与部署的完整流程。对于希望深入理解MMORPG架构的开发者而言,这份指南是宝贵的实战资源。

weixin_28363123的博客 74

【置顶】ARMv8/ARMv9架构入门到精通-[目录]

周贺贺,baron,代码改变世界,coding_the_world,Arm精选,arm_2023,安全启动,加密启动 optee、ATF、TF-A、Trustzone、optee3.14、MMU、VMSA、cache、TLB、arm、armv8、armv9、TEE、安全、内存管理、页表,Non-cacheable,Cacheable, non-shareable,inner-shareable,outer-shareable, optee、ATF、TF-A、Trustzone、optee3.14、MMU、V

baron-周贺贺-代码改变世界ctw 2万+

jsp页面下载txt文件

jsp页面超链接下载txt文件时,页面并没有提示打开保存,而是在jsp页面中直接将内容显示出来。若要提示保存,则需要进行以下设置。(下面是一个例子) jsp页面代码:     pageEncoding="gb2312"%> 文件下载 String fileName = "text.txt";//将要下载的txt文件名,当然也可以根据参数获取 S

kmiii的专栏 1460

第二篇:APS智能排产实战:OR-Tools与coptpy从入门到案例

专注于具体的技术实现,包括 OR-Tools 和 coptpy 的详细使用指南、建模技巧、日志解读,以及一个完整的两阶段生产排程案例。适合准备动手开发 APS 系统的工程师和研究者。

算法工程师 455

jsp 下载txt文件和excel文件

<!--google_ad_client = "pub-4490194096475053";/* 内容页,300x250,第一屏 */google_ad_slot = "3685991503";google_ad_width = 300;google_ad_height = 250;//--><script type="text/javascript"src="

管子(zero)的杂乱空间 1433

ROS2 Nav2 - 模型预测路径积分控制器(MPPI)

这是一个预测控制器(局部轨迹规划器),用于实现模型预测路径积分(MPPI)算法,以跟踪具有自适应避障功能的路径。它包含基于插件的 critic 函数,可影响算法的行为。它由 Aleksei Budyakov 创建,由 Steve Macenski 为 Nav2 进行改编和开发。该插件实现了 nav2_core::Controller(控制器)接口,可在整个导航堆栈中作为控制器服务器的动作服务器(controller_server)中的局部轨迹规划器使用。据测定,该控制器可在中等英特尔处理器(第四代 i5)上

机器人控制与仿真应用 3914

jre9下载 jdk9

(Java SE Runtime Environment 9.0) 9.0u175 官方最新版 【x86|x64】

java jsp下载txt文件_JSP下载txt 和 Excel两种文件

1下载txt文件这个花了我不少时间 原因是用ie下载txt文件时是在页面中直接打开了文件.虽然查了一些资料,也看了别人的解决方案,可还是解决不了问题,最后发现是一个字母惹的祸:少写一个字母 嘿嘿 够马虎!!!代码如下:OutputStream o=response.getOutputStream();byte b[]=new byte[500];File fileLoad=new File("e:...

weixin_34357614的博客 346

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

exls下载后显示jsp_JSP下载txt 和 Excel两种文件

最近做了个用jsp下载的页面 将代码贴出来 权作记录吧1 下载txt文件这个花了我不少时间 原因是用ie下载txt文件时是在页面中直接打开了文件.虽然查了一些资料,也看了别人的解决方案,可还是解决不了问题,最后发现是一个字母惹的祸:少写一个字母 嘿嘿 够马虎!!!代码如下:OutputStream o=response.getOutputStream();byte b[]=new byte[500...

weixin_39806065的博客 244

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

JSP下载txt 和 Excel两种文件

1 下载txt文件  这个花了我不少时间 原因是用ie下载txt文件时是在页面中直接打开了文件.虽然查了一些资料,也看了别人的解决方案,可还是解决不了问题,最后发现是一个字母惹的祸:少写一个字母 嘿嘿 够马虎!!! 代码如下: OutputStream o=response.getOutputStream();    byte b[]=new byte[500];    Fi

z69183787的专栏 4409

jsp中实现普通文件下载

jsp中实现普通文件下载 Author:lyore Date:2007-03-13 20:45 本程序实现的是将中文字符和数字写入文件"导出数据.txt"中,实际上不仅仅限于txt文件,可以为任何在服务器web.xml文件中定义的类型文件  page language="java" import="java.io.*" pageEncodin

robin622的专栏 607

如何点击连接直接下载.txt文本文件

挺好用的。原文:Jsp代码 "Content-Type" content="text/html; charset=gbk">                   "download1.jsp?filepath=d://&filename=1a.txt" >downloadtest1          

deergao的专栏 2663
上一篇: JAVA 读取文件进行排序取出最后变更的的文件
xiaodanjava
博客等级 码龄15年 90粉丝 26原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值