Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/369.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 连接错误:";org.jsoup.UnsupportedAdminType异常:未处理的内容类型;_Java_Jsoup_Httpconnection - Fatal编程技术网

Java 连接错误:";org.jsoup.UnsupportedAdminType异常:未处理的内容类型;

Java 连接错误:";org.jsoup.UnsupportedAdminType异常:未处理的内容类型;,java,jsoup,httpconnection,Java,Jsoup,Httpconnection,当我试图打开一个链接来解析jsoup时,我得到一个错误 连接命令: Document doc = Jsoup.connect("http://www.rfi.ro/podcast/emisiune/174/feed.xml") .timeout(10 * 1000).get(); 引发的错误: 线程“main”org.jsoup.UnsupportedAdminTypeException中的异常:未处理的内容类型。必须是text/*、application/xm

当我试图打开一个链接来解析jsoup时,我得到一个错误

连接命令:

Document doc = Jsoup.connect("http://www.rfi.ro/podcast/emisiune/174/feed.xml")
                .timeout(10 * 1000).get();
引发的错误:

线程“main”org.jsoup.UnsupportedAdminTypeException中的异常:未处理的内容类型。必须是text/*、application/xml或application/xhtml+xml。Mimetype=application/rss+xml;字符集=utf-8,URL=http://www.rfi.ro/podcast/emisiune/174/feed.xml
位于org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:453)
位于org.jsoup.helper.HttpConnection$Response.execute(HttpConnection.java:410)
位于org.jsoup.helper.HttpConnection.execute(HttpConnection.java:164)
位于org.jsoup.helper.HttpConnection.get(HttpConnection.java:153)
位于podcast.Pods.main(Pods.java:41)

使用
忽略内容类型()


很好,在我的例子中,像charmin一样工作,requestBody属性不在connect对象中。
String myURL = "http://www.rfi.ro/podcast/emisiune/174/feed.xml";
Document pod = Jsoup.connect(myURL).ignoreContentType(true).get();
// Initialize UnSupportedMimeTypeExeception class 
UnsupportedMimeTypeException mimeType = new UnsupportedMimeTypeException("Hey this is Mime",  "application/json", "http://dictionary.cambridge.org/dictionary/english/reality");
String mime = mimeType.getMimeType();

Document doc = Jsoup.connect("https://translate.google.com/translate_a/single?client=t&sl=en&tl=hi&hl=en&dt=at&dt=bd&dt=ex&dt=ld&dt=md&dt=qca&dt=rw&dt=rm&dt=ss&dt=t&ie=UTF-8&oe=UTF-8&source=bh&ssel=0&tsel=0&kc=1&tk=2546.416541&q=consume")
    .requestBody("JSON")
    .header("Content-Type", mime)
    .cookies(response.cookies())
    .ignoreContentType(true)
    .post();
System.out.println(doc);