【问题标题】:What is equivalent of jQuery.ajax dataType raw in Spring RestTemplateSpring RestTemplate 中的 jQuery.ajax dataType raw 等价物
【发布时间】:2018-05-17 16:54:11
【问题描述】:

我有如下的 jquery ajax 调用

jQuery.ajax(url, {
        headers  : header_settings,
        type     : "POST",
        dataType : "raw",
        data     : JSON.stringify(data),
        success  : callback,
        error    : callback
      });

我们应该如何为 Spring RestTemplate 指定 dataType raw

RestTemplate restTemplate = new RestTemplate();
.....
    restTemplate.postForObject(uri, request, String.class);

【问题讨论】:

  • 在 jQuery 中,没有名为 rawdataType。您可以查看here。支持的类型是(xml, json, script, or html)。事实上,您已经使用 JSON.stringify(..)! 将数据设置为 JSON 字符串
  • 感谢济科。是的,明白了。

标签: javascript jquery ajax spring


【解决方案1】:

智能猜测是默认设置,通常对我有用。您可以删除 dataType 行。

【讨论】:

    猜你喜欢
    • 2013-01-05
    • 1970-01-01
    • 1970-01-01
    • 2014-02-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-13
    相关资源
    最近更新 更多