为什么提交FormPanel后onSubmitComplete()没有执行?

Why is onSubmitComplete() not executed after submitting FormPanel?

我有一个提交信用卡信息数据的表格:

<g:FormPanel ui:field="creditCardForm" action="/app/create-credit-card" method="post">
    <g:HTML>
        <input data-braintree-name="number" value="4111111111111111"/>
        <input data-braintree-name="cvv" value="100"/>

        <input data-braintree-name="expiration_date" value="10/20"/>

        <input data-braintree-name="postal_code" value="94107"/>
        <input data-braintree-name="cardholder_name" value="John Smith"/>
    </g:HTML>
   </g:FormPanel>

但是由于某些原因 SubmitCompleteHandlerPOST 完成后没有生效:

this.creditCardForm.addSubmitHandler(new SubmitHandler() {

    @Override
    public void onSubmit(SubmitEvent event) {
        LOGGER.fine("onSubmit()");
    }
});

this.creditCardForm.addSubmitCompleteHandler(new SubmitCompleteHandler() {
    @Override
    public void onSubmitComplete(SubmitCompleteEvent event) {
        LOGGER.fine("complete ..");
        LOGGER.fine("Submit result: " + event.getResults());
    }
});

Servlet 仅返回 String 并写入一些调试消息:

public class CreateCreditCardServlet extends HttpServlet implements Servlet {

    private final static Logger LOGGER = Logger.getLogger(CreateCreditCardServlet.class.getName());

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, java.io.IOException {          LOGGER.debug("#########################################################");
        LOGGER.debug("doPost");
        LOGGER.debug("#########################################################");
        resp.getOutputStream().println("This is servlet response");
    }
}

我在开发者工具中看到了响应,但为什么没有调用处理程序?

来自 FormPanel 文档:

The back-end server is expected to respond with a content-type of 'text/html', meaning that the text returned will be treated as HTML. If any other content-type is specified by the server, then the result HTML sent in the onFormSubmit event will be unpredictable across browsers, and the onSubmitComplete event may not fire at all.

所以,在 servlet 中你需要做类似的事情:

resp.setContentType("text/html")