我想在浏览器中从新空白打开 pdf 文件:
String sCommand = GWT.getHostPageBaseURL() + "requiredPDF?vCompanyName="+ companyName + "&" +
"vCurDate=" + new Date().getTime() + "&" +
sTitle +
"vReportType=" + rt.reportType +"&" +
"vChartType=" + rt.iChartType +"&" +
sParameters +
"vDetalization=" + rt.detalization + "&" +
"vGroup=" + getCheckedGroups();
Window.open(sCommand,"", "");
这很好用。但是,我想使用 doPOST 方法,据我了解, Window.open() 只能与 doGET 方法一起使用。我已经为 doPOST 寻找了一些问题,但它们没有打开导致新浏览器的空白/窗口。
如何使用doPOST
方法在新浏览器的空白中显示结果?
更新。我将代码更改为与 doPOST 而不是 window.open() 绑定,但没有任何反应
String sURL = GWT.getHostPageBaseURL() + "requirePDF";
String sData = "vCompanyName="+ companyName + "&" +
"vCurDate=" + new Date().getTime() + "&" +
sTitle +
"vReportType=" + rt.reportType +"&" +
"vChartType=" + rt.iChartType +"&" +
sParameters +
"vDetalization=" + rt.detalization + "&" +
"vGroup=" + getCheckedGroups();
RequestBuilder builder = new RequestBuilder(RequestBuilder.POST, sURL);
builder.sendRequest(sData, new RequestCallback() {
@Override
public void onResponseReceived(Request request, Response response) {
FormPanel formPanel = new FormPanel();
formPanel.setAction(GWT.getHostPageBaseURL() + "requirePDF");
formPanel.setMethod(FormPanel.METHOD_POST);
//formPanel.submit();
formPanel.setVisible(true);
rt.add(formPanel);
}
@Override
public void onError(Request request, Throwable exception) {
MessageBox.alert("Request error","The page doesn't open", null);
}
});