0

我有下一个问题......当我提交表单并且我的 Post 方法结束时。表单(或不)抛出空警报窗口。我怎样才能删除这个投掷窗口?

客户端

 ....            
        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();
            }
        }
    }

也许有人知道这个警报的原因?

4

1 回答 1

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

如果他们正在构建一个字符串作为响应并通过其他一些机制显示它,那么它不太可能而且还搜索你的服务器端代码库。

于 2012-12-03T05:23:23.420 回答