GWT上传错误FileNotFoundException

时间:2015-02-04 08:58:45

标签: gwt file-upload

我正在上传服务器上的文件,如下所示:我在服务器上创建文件夹,然后将所有上传文件放在此文件夹中

@Override
    public String executeAction(HttpServletRequest request,
            List<FileItem> sessionFiles) throws UploadActionException {
        String response = "";
        int cont = 0;
        userNumber = request.getParameter("userNumber");
        File f = new File(ConfAppServer.getRealContextPath() + "/edoc/"
                + userNumber);
        for (FileItem item : sessionFiles) {
            if (false == item.isFormField()) {
                cont++;
                try {
                    String extension = item.getName().substring(
                            item.getName().length() - 3);
                    File file = null;
                    file = new File(ConfAppServer.getRealContextPath()
                            + "/edoc/"
                            + userNumber
                            + System.getProperty("file.separator")
                            + item.getName().substring(0,
                                    item.getName().length() - 4) + "."
                            + extension);
                    item.write(file);

                    receivedFiles.put(item.getFieldName(), file);
                    receivedContentTypes.put(item.getFieldName(),
                            item.getContentType());

                    response += "<file-" + cont + "-field>"
                            + item.getFieldName() + "</file-" + cont
                            + "-field>\n";
                    response += "<file-" + cont + "-name>" + item.getName()
                            + "</file-" + cont + "-name>\n";
                    response += "<file-" + cont + "-size>" + item.getSize()
                            + "</file-" + cont + "-size>\n";
                    response += "<file-" + cont + "-type>"
                            + item.getContentType() + "</file-" + cont
                            + "type>\n";
                } catch (Exception e) {
                    throw new UploadActionException(e);
                }
            }
        }
        removeSessionFileItems(request);
        return "<response>\n" + response + "</response>\n";
    }

它在我的同事计算机上运行良好,但在我的计算机上我收到错误 enter image description here

文件名中有错误。请帮我解决我的问题。感谢。

0 个答案:

没有答案