2012-12-02 50 views
0

我有下一個問題...當我提交表單和我的Post方法結束。表單(或不)拋出空警報窗口。我怎樣才能刪除這個投擲窗口?提交FormPanel後提示窗口

ClienSide

....    
     final FormPanel form = new FormPanel(); 
     form.setAction(GWT.getModuleBaseURL()+"upload"); 

     form.setEncoding(FormPanel.ENCODING_MULTIPART); 
     form.setMethod(FormPanel.METHOD_POST); 

     VerticalPanel panel = new VerticalPanel(); 
     form.setWidget(panel); 

     FileUpload upload = new FileUpload(); 
     upload.setName("uploadFormElement"); 
     panel.add(upload); 

     fileButton.addClickHandler(new ClickHandler() { 
      public void onClick(ClickEvent event) { 
       form.submit(); 
      } 
     }); 

FileUploadServlet

public class FileUploadServlet extends HttpServlet { 

    @Override 
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) 
      throws ServletException, IOException { 
     super.doGet(req, resp); 
    } 

    @Override 
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) 
      throws ServletException, IOException { 


     if (ServletFileUpload.isMultipartContent(req)) { 
      FileItemFactory factory = new DiskFileItemFactory(); 
      ServletFileUpload upload = new ServletFileUpload(factory); 

      try { 
       List<FileItem> items = upload.parseRequest(req); 
       for (FileItem fileItem : items) { 
        if (fileItem.isFormField()) continue; 
        String fileName = fileItem.getName(); 
        if (fileName != null) { 
         fileName = FilenameUtils.getName(fileName); 
        } 
        File uploadedFile = new File("test.txt"); 
        if (uploadedFile.createNewFile()) { 
         fileItem.write(uploadedFile); 
        } 

       } 
      } catch (FileUploadException e) { 
       e.printStackTrace(); 
      } catch (Exception e) { 
       e.printStackTrace(); 
      } 
     } 
    } 

也許有人知道此警報的原因?

+1

如果您發佈了錯誤日誌並且還有屏幕截圖,這將有所幫助。如果它是本地窗口,請嘗試在客戶端代碼庫中搜索Window.alert。 – SSR

+0

這不是錯誤,只是空的警報窗口。 – Classico

+0

螢火蟲控制檯打開的「警報」屏幕截圖會爲問題添加一些細節:) – SSR

回答

3

如果您需要跟蹤/搜索它在三個地方

一個簡單的JavaScript警告窗口

步驟 - 跨客戶端代碼搜索警報字符串

1) In javascript - third party .js file . String search for `alert` in such js files 

2) In third party gwt jar . 
a) String search for Window.alert in the GWT java code 
b) String search for wnd.alert in GWT jsni code 

3) In Your own source code - repeat steps "a" and "b" from Step 2 

這是不可能的,但也字符串搜索你的服務器端代碼庫,如果他們正在建立一個字符串作爲響應,並通過其他機制顯示它。