简体   繁体   English

GWT FileUpload - 通过客户端代码设置响应 Content-Type

[英]GWT FileUpload - Set the response Content-Type through Client code

I have a file upload form in GWT and the upload process works fine.我在 GWT 中有一个文件上传表单,上传过程正常。 Though, I have problem getting the response.但是,我在获得响应时遇到了问题。 The response capturing code is:响应捕获代码为:

formUpload.addSubmitCompleteHandler(new FormPanel.SubmitCompleteHandler() {
    @Override
    public void onSubmitComplete(final SubmitCompleteEvent event) {
        fileUploadControl.handleResponse(htmlToText(event.getResults()));
    }
});

The event.getResults() always results in null . event.getResults()总是导致null Upon investigating, I found that the response Content-Type should be one of text/html or text/plain .经过调查,我发现响应Content-Type应该是text/htmltext/plain In my case, it is application/xml and I can't control the server response as well.就我而言,它是application/xml ,我也无法控制服务器响应。

I was wondering if it is possible to set Accept request header in file upload form.我想知道是否可以在文件上传表单中设置Accept请求标头。 If it is not possible, any other suggestion is appreciated.如果这是不可能的,任何其他建议表示赞赏。

See documentation SubmitCompleteEvent#getResults请参阅文档SubmitCompleteEvent#getResults

public java.lang.String getResults() Gets the result text of the form submission. public java.lang.String getResults()获取表单提交的结果文本。
Returns:返回:
the result html, or null if there was an error reading it结果 html,如果读取时出错,则为 null
Tip:小费:
The result html can be null as a result of submitting a form to a different domain.由于将表单提交到不同的域,结果 html 可能为 null。

If It is working without errors, maybe domains are different.如果它正常工作,则域可能不同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM