How to post data and redirect to another page using GWT?

前端 未结 2 831
孤街浪徒
孤街浪徒 2021-01-14 14:39

When I press a button I post some data to server and there redirect to another page. I used RequestBuilder but it is waiting the response, and of course get it. And nothing

2条回答
  •  粉色の甜心
    2021-01-14 15:25

        FormPanel form = new FormPanel("_self");
        form.setMethod(FormPanel.METHOD_GET);
    
        Hidden params0 = new Hidden("param1", "value1");
        Hidden params1 = new Hidden("param1", "value2");
        Hidden params2 = new Hidden("param2", "value3");
    
        FlowPanel panel = new FlowPanel();
        panel.add(params0);
        panel.add(params1);
        panel.add(params2);
    
        form.add(panel);
    
        form.setAction(GWT.getModuleBaseURL() + "../MyServlet");
        RootPanel.get().add(form);
        form.submit();
    

    Thats it. The code adds FormPanel and sends form.

提交回复
热议问题