简体   繁体   中英

GWT FileUpload - Set the response Content-Type through Client code

I have a file upload form in GWT and the upload process works fine. 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 . Upon investigating, I found that the response Content-Type should be one of text/html or text/plain . In my case, it is application/xml and I can't control the server response as well.

I was wondering if it is possible to set Accept request header in file upload form. If it is not possible, any other suggestion is appreciated.

See documentation SubmitCompleteEvent#getResults

public java.lang.String getResults() Gets the result text of the form submission.
Returns:
the result html, or null if there was an error reading it
Tip:
The result html can be null as a result of submitting a form to a different domain.

If It is working without errors, maybe domains are different.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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