未处理的内容类型错误

时间:2012-10-27 19:28:53

标签: jsoup gson

获取Gson字符串的代码:

String data = Jsoup.connect("http://localhost:9000/GetJson").get().data();
来自主机的

“HTML”内容:9000 / GetJson:

{"Backend":"{\"onlineGames\":{},\"games\":{}}"}

我发出此错误消息:

Unhandled content type. Must be text/*, application/xml, or application/xhtml+xml

有人可以告诉我我错在哪里:(
非常感谢你。

3 个答案:

答案 0 :(得分:1)

Jsoup不支持Gson / Json,只支持Html,Xhtml和Xml 如果你想使用jsoup,你必须将你的gson字符串包装成html。但是你想做什么?也许我们可以帮助你。

答案 1 :(得分:0)

使用 ignoreContentType(true)

String data = Jsoup.connect("http://localhost:9000/GetJson").get().ignoreContentType(true).data(

答案 2 :(得分:0)

    Document doc = Jsoup.connect(url).ignoreContentType(true).get();
相关问题