dhtmlxVault是一个基于AJAX技术开发,包含进度条的DHTML JavaScript 多文件上传组件。界面如下:

处理dhtmlxVault框架的isHexDigit异常

按照其提供的例子我们很容易在项目中使用。但是要注意中文乱码问题。

在其提供的UploadHandler.jsp文件中我们需加上下面语句:

request.setCharacterEncoding("UTF-8");

当然如果你使用字符编码过滤器则不需要考虑。

通过如上的设置,我们可以正常的上传包含中文名的文件,但是服务器会抛java.io.CharConversionException: isHexDigit 异常。

百度后了解需要使用encodeURI处理URL,于是打开dhtmlxvault.js文件,杯具,代码惨不忍睹,使用工具格式化代码。

找到这句代码:

this.uploadForm.action = this.pathUploadHandler + "?sessionId=" + this.sessionId + "&fileName=" + escape(this.getFileName(this.getCurrentInputFile(id).value)) + "&userfile=" + this.getCurrentInputFile(id).id;

修改成:

this.uploadForm.action = encodeURI(this.pathUploadHandler + "?sessionId=" + this.sessionId + "&fileName=" + this.getFileName(this.getCurrentInputFile(id).value) + "&userfile=" + this.getCurrentInputFile(id).id);

即可解决。

相关文章:

  • 2022-12-23
  • 2021-10-09
  • 2022-12-23
  • 2021-09-14
  • 2021-09-21
  • 2021-08-08
  • 2021-10-17
  • 2021-07-24
猜你喜欢
  • 2022-12-23
  • 2021-09-23
  • 2022-12-23
  • 2021-12-01
相关资源
相似解决方案