博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
使用resttemplate post json
阅读量:6912 次
发布时间:2019-06-27

本文共 602 字,大约阅读时间需要 2 分钟。

  hot3.png

##实例

String url = "http://demo/api/book/";        HttpHeaders headers = new HttpHeaders();        MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");        headers.setContentType(type);        String requestJson = "{...}";        HttpEntity
entity = new HttpEntity
(requestJson,headers); String result = restTemplate.postForObject(url, entity, String.class); System.out.println(result);

##设置contentType解决中文乱码

MediaType type = MediaType.parseMediaType("application/json; charset=UTF-8");

转载于:https://my.oschina.net/go4it/blog/777894

你可能感兴趣的文章
2-openstack基础环境准备
查看>>
SVN安装采用AD认证
查看>>
hive常用语法示例
查看>>
unicode分类
查看>>
hadoop-003-源码之编译eclipse-plugin
查看>>
即使对象内容都为空,对象本身也是非空的
查看>>
MySQL事务隔离级别详解
查看>>
storm记录--3--Storm的基本概念
查看>>
×××灯marquee标签应用详解
查看>>
彻底弄懂css中单位px和em,rem的区别
查看>>
我的友情链接
查看>>
MapReduce的输出格式
查看>>
AD帐号属性灰色不能修改--解决办法
查看>>
当子页面关闭的时候动态刷新页面的局部
查看>>
javascript 去掉重复的值
查看>>
[置顶] jQuery基础学习(一)
查看>>
SIP Servlet 开篇
查看>>
我在IT中的那些转变
查看>>
用户管理 之 Linux 用户管理工具介绍
查看>>
UIScrollView 滚动视图
查看>>