CodingStudying

练习-uploadFile记录

2016-10-24  本文已影响15人  7ack

上传文件报错

[ERROR]file upload error.
java.lang.StringIndexOutOfBoundsException: String index out of range: -1

报错的代码 officeUtil.java

String htmlPath = filePath.substring(0,filePath.lastIndexOf("/"))+"/html";
String htmlPath = filePath.substring(0,filePath.lastIndexOf("\\"))+"\\html";

不报错,但是涉及到了路径的更改,感觉windows的路径和其他系统的不一样,可能会影响其他平台的使用?

  1. 将property的path全部改成c:/
  2. 因为windows也可访问/的路径 除了 String htmlPath = filePath.substring(0,filePath.lastIndexOf("\\"))+"\\html";其他全部改成/
  3. 上传图片无法显示预览

连接本地的openOffice服务错误

connection failed: socket,host=localhost,port=8100,tcpNoDelay=1

查看报错的文件

Source not found
The JAR file C:\.....\jodconveter-2.2.2.jar has no source attachment.

获取OpenOffice连接失败

connection failed: socket,host=localhost,port=8100,tcpNoDelay=1
soffice -headless -accept="socket,host=127.0.0.1,port=8100;urp;" -nofirststartwizard 
         String command =  "C:\\Program Files (x86)\\OpenOffice 4\\program\\soffice.exe -headless -accept=\"socket,host=127.0.0.1,port=8100;urp;\" -nofirststartwizard ";  
         Process pro = Runtime.getRuntime().exec(command);  

        // 创建Openoffice连接
        OpenOfficeConnection con = new SocketOpenOfficeConnection(8100);
        try {
            // 连接
            con.connect();
        } catch (ConnectException e) {
            logger.error("获取OpenOffice连接失败...",e);
        }
        // 创建转换器
        DocumentConverter converter = new OpenOfficeDocumentConverter(con);
        // 转换文档问html
        converter.convert(docFile, htmlFile);
        // 关闭openoffice连接
        con.disconnect();
        //关闭openOffice服务
        pro.destroy();
update pic_info SET business_type = 201, pic_url = '/announcement/2016/10/15/3329715835213.xls', 
file_type = 'xls', real_name = 'xx工作周报.xls', html_path = 'C:\app\ftp\announcement\2016\10\15\html\3332052044145.html' 
where id = 613311
  1. 将openOffice的command加在了property文件中,便于修改.
  2. 解决了openOffice转码html后乱码的问题:更改openOffice配置,将字符格式设置为utf-8,将输出设置为html3.2

404错误

警告: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:vj-practice-manager' did not find a matching property.

The solution to this problem is very simple. Double click on your tomcat server. It will open the server configuration. Under server options check ‘Publish module contents to separate XML files’ checkbox. Restart your server. This time your page will come without any issues.

完成上传后,点击编辑,显示loading动画后卡死

上一篇 下一篇

猜你喜欢

热点阅读