【发布时间】:2019-02-17 11:44:13
【问题描述】:
我想将我的标题内容类型从 text/html 更改为 application/json。 我当前的标题是:{CamelHttpMethod=POST,, CONTENT_TYPE=application/json}
我想删除 Content-Type=text/html; charset=UTF-8 通过在如下进程中设置标头:
public void process(Exchange exchange) throws Exception {
String mainBody = exchange.getIn().getBody().toString();
JsonReader reader = Json.createReader(new StringReader(mainBody));
JsonObject body = reader.readObject();
reader.close();
exchange.getIn().setHeaders(exchange.CONTENT_TYPE, simple("application/json"));
/System.out.println("your header" + exchange.getIn().getHeaders());
exchange.getIn().setBody(body.getJsonObject("API3"));
}
}
有可能吗?
【问题讨论】:
标签: json rest http-headers