`
icarusliu
  • 浏览: 232183 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

webDav遇到的乱码问题

阅读更多

在用jspSmartUpload上传文件的过程当中,开始使用以下代码的时候出现乱码:

 

WebdavResource pwr = GetWebdavResource.getWDR(wrPath);
pwr.putMethod(wrPath + fileName, file.getContentString());

 

 后来采用另外一种方法,乱码解决:

 

WebdavResource pwr = GetWebdavResource.getWDR(wrPath);
pwr.putMethod(wrPath + fileName, file.getContentString().getBytes());

 

 

发现如果在jsp页面直接传一个文件对象过去然后在程序当中再取文件名的时候文件名会出现乱码,但如果先在jsp页面当中取得文件名然后再传过去,就不会出现乱码了。如在jsp页面调用以上代码:

 

OperateWebdavResource owr = new OperateWebdavResource();
owr.uploadFile(wrPath,file,new String(file.getFileName().getBytes(),"UTF-8"));
 这边传了一个fileName过去了,如果没有传而是在java中利用file来取得文件名,就会出现文件名的乱码。
分享到:
评论
1 楼 glamey 2010-12-23  
文件上传最好还是自己来写,不要用网上那么多的开源框架,不好的。直接用apache里边的common-fileupload最直接了。

相关推荐

Global site tag (gtag.js) - Google Analytics