我有下一个问题...当我提交表单并且我的Post方法结束时。表单(或不表示)抛出空警报窗口。如何删除这个投掷窗口?
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();
}
}
}
也许有人知道这个警报的原因?
答案 0 :(得分: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
如果他们在响应中构建一个字符串并通过其他机制显示它,那么它不太可能,但也会搜索服务器端代码库。