【问题标题】:How to extract the value of serialized JSON String out of the POST HttpRequest with spring Resttemplate如何使用spring Resttemplate从POST HttpRequest中提取序列化JSON字符串的值
【发布时间】:2014-05-14 18:16:32
【问题描述】:

我正在尝试在 restTemplate 中发送一个带有 POST HttpRequest 的对象。

restTemplate.postForObject(urlPOST, "POST", Some.class, someObject);

出于调试目的,我想从 springs restTemplate 对象中获取序列化的 JSON 字符串。

我在哪里以及如何访问发送到服务器的 json 字符串?

【问题讨论】:

  • 您可以在客户端和服务器之间放置一个代理并捕获网络上的字符串
  • 太晚了!!!这是将近一年前的事了,但感谢您的意见。

标签: json spring resttemplate


【解决方案1】:

你可以在课堂上设置断点

public abstract class AbstractHttpMessageConverter<T> implements HttpMessageConverter<T>

在方法中

public final void write(T t, MediaType contentType, HttpOutputMessage
 outputMessage)

看看转换后的字符串是什么!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-21
    • 1970-01-01
    • 1970-01-01
    • 2018-04-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多