无法通过请求构建器发送发布参数

时间:2019-02-05 11:13:41

标签: java rest gwt http-post

它正在打开新窗口,但没有使用GWT将Post参数传递到新窗口。

final RequestBuilder rb = new RequestBuilder(RequestBuilder.POST, encodedUrl);
rb.setHeader("Content-type", "application/x-www-form-urlencoded");
rb.setRequestData(json);
Request response = rb.sendRequest(json.toString(), new RequestCallback() {
    public void onError(Request request, Throwable exception) {}
    public void onResponseReceived(Request request, Response response) {
        Window.open(rb.getUrl(), postTarget, postWinFeatures);
    }
});

1 个答案:

答案 0 :(得分:0)

FormPanel表单=新的FormPanel(目标);

                form.setMethod(FormPanel.METHOD_POST);
                form.setEncoding(FormPanel.ENCODING_URLENCODED);
                Hidden params0 = new Hidden("dds", "xyz");
                Hidden params1 = new Hidden("sdsdsd", "sdsd");
                Hidden params2 = new Hidden("sdsd", "sdsdd");

                FlowPanel panel = new FlowPanel();
                panel.add(params0);
                panel.add(params1);
                panel.add(params2);

                form.add(panel);
                //form.add(buildPostURLParameter());
                form.setAction(buildPostURL());
                RootPanel.get().add(form);
                form.submit();