当前位置: 技术问答>java相关
jsp下载文件时文件名到客户端时乱码?就是保存的时候,望高手指点!
来源: 互联网 发布时间:2015-09-26
本文导语: 由于下载的文件是从别的机器上读过来的,因此不能直接连接下载,只是中文文件名出错。 代码如下: response.setContentType("APPLICATION/OCTET-STREAM;charset=ISO-8859-1"); response.setHeader("Content-Disposition","attachment; filename="" + dow...
由于下载的文件是从别的机器上读过来的,因此不能直接连接下载,只是中文文件名出错。
代码如下:
response.setContentType("APPLICATION/OCTET-STREAM;charset=ISO-8859-1");
response.setHeader("Content-Disposition","attachment; filename="" + downloadname + """);
java.io.FileInputStream fileInputStream = new java.io.FileInputStream(filepath + filename);
int i;
while ( (i=fileInputStream.read()) != -1 ) {
out.write(i);
}
fileInputStream.close();
out.close();
代码如下:
response.setContentType("APPLICATION/OCTET-STREAM;charset=ISO-8859-1");
response.setHeader("Content-Disposition","attachment; filename="" + downloadname + """);
java.io.FileInputStream fileInputStream = new java.io.FileInputStream(filepath + filename);
int i;
while ( (i=fileInputStream.read()) != -1 ) {
out.write(i);
}
fileInputStream.close();
out.close();
|
这是我做的关于CSV下载到客户端的问题!!
你自己参考一下吧!!!
public void CSVOUT(ClientRowSet rsQuery)
{
try
{
BufferedWriter bufout;
File FilePath = new File(strCSVOUT_PATH+"\"+
this.getSessionParam().getValueAsString(CMN_APP_ColConstant.MANNO)
+"_nof.csv");
bufout = new BufferedWriter(new FileWriter(FilePath));
bufout.write(",休暇届出設定,,");
bufout.newLine();
bufout.write("届出コード,届出内容,対象MHシート,日数");
String outRow ="";
rsQuery.moveFirst();
for (int i=0;i
你自己参考一下吧!!!
public void CSVOUT(ClientRowSet rsQuery)
{
try
{
BufferedWriter bufout;
File FilePath = new File(strCSVOUT_PATH+"\"+
this.getSessionParam().getValueAsString(CMN_APP_ColConstant.MANNO)
+"_nof.csv");
bufout = new BufferedWriter(new FileWriter(FilePath));
bufout.write(",休暇届出設定,,");
bufout.newLine();
bufout.write("届出コード,届出内容,対象MHシート,日数");
String outRow ="";
rsQuery.moveFirst();
for (int i=0;i