您的位置:程序门 -> java -> web 开发



开发下载操作,下载的文件后缀名消失


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


开发下载操作,下载的文件后缀名消失[无满意答案结贴,结贴人:zrwlc2008]
发表于:2007-09-07 15:12:05 楼主
我用了smartupload组件做下载操作。当我用下载中文的文件时。会发现我的后缀名丢失,但是非中文的就可以。 /**  
  *   method   EXECute
  *   @param   mapping
  *   @param   form
  *   @param   request
  *   @param   response
  *   @return   actionforward
  *   下载
  */
public   actionforward   download(actionmapping   mapping,   actionform   form,httpservletrequest   request,   httpservletresponse   response)   {
try{
string   mimetype=request.getparameter( "url ");
if(mimetype.equals( " ")){
system.out.println( "没有下载地址 ");
}else{
smartupload   su   =   new   smartupload();
su.initialize(getservlet().getservletconfig(),request,response);
string   filename=util.toutf8string(mimetype);
response.reset();  
response.setcontenttype( "utf-8 ");
string   filepath   =   urldecoder.decode(filename, "utf-8 ");
response.addheader( "content-disposition ", "attachment;filename= "   +   filepath);
su.downloadfile( "/datefile/ "+filepath);
}
}catch(exception   e){e.printstacktrace();}
return   mapping.findforward( " ");
}


快速检索

最新资讯
热门点击