Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/gwt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
GWT中的表单提交错误_Gwt - Fatal编程技术网

GWT中的表单提交错误

GWT中的表单提交错误,gwt,Gwt,我的代码是 FormPanel form =new FormPanel(); VerticalPanel holder = new VerticalPanel(); holder.add(new Label("User ID")); nameTextBox = new TextBox(); nameTextBox.setName("userid"); h

我的代码是

            FormPanel form =new FormPanel();
            VerticalPanel holder = new VerticalPanel();
            holder.add(new Label("User ID"));
            nameTextBox = new TextBox();
            nameTextBox.setName("userid");
            holder.add(nameTextBox);

             submitButton = new Button("Submit");
             holder.add(submitButton);
            form.add(holder);

            submitButton.addClickListener(new ClickListener() {

            @Override
            public void onClick(Widget sender) {
                    form.submit();
            }

            });

            form.addFormHandler(new FormHandler() {
                    public void onSubmit(FormSubmitEvent event) {


           }

           public void onSubmitComplete(FormSubmitCompleteEvent event) {

        }
      });
但当我提交表格时,我会出错

[错误]未捕获异常已转义 com.google.gwt.core.client.JavaScriptException:(TypeError):form.submit不是一个函数

请告诉我正确的方法。

只需添加form.setAction(“/pathfthesubmission”)

或者,如果您发送了文件,也可以添加以下内容:

form.setEncoding(FormPanel.ENCODING\u MULTIPART);
form.setMethod(FormPanel.METHOD_POST)

您使用的是哪个版本的gwt,请给我“Form”class.import.com.google.gwt.user.client.ui.FormPanel的导入语句;在您的代码中,您提到了“Form Form=new Form();”(代码的第一行)。但是您正在导入Formpanel。请您澄清一下,也可以调用Form.setAction(“您的URL”)方法。