HttpURLConnection如何添加请求头?

1.conn.setRequestProPerty(name,value),两个参数都是字符串。。。。

2.用httpURLConnection的setRequestProPerty(name,value)方法,就能向header里添加信息。

如:设置content-type

httpURLConnection.setRequestProperty("token", "10051:abc");
        httpURLConnection.setRequestProperty("Content-type", "application/json"); 

 

posted @ 2016-12-09 10:29  跨境电商杂货铺  阅读(85664)  评论(0编辑  收藏  举报