Java 类型Connection.KeyVal的Jsoup方法头(String,String)未定义
我使用的是Jsoup版本1.9.2,代码如下:Java 类型Connection.KeyVal的Jsoup方法头(String,String)未定义,java,connection,jsoup,Java,Connection,Jsoup,我使用的是Jsoup版本1.9.2,代码如下: public static String reQuest(String tUri, org.jsoup.Connection.Method Met, String postData) throws IOException { Response res = null; try { res = Jsoup.connect( tUri ) .ignoreContentType( true )
public static String reQuest(String tUri, org.jsoup.Connection.Method Met, String postData) throws IOException {
Response res = null;
try {
res = Jsoup.connect( tUri )
.ignoreContentType( true )
.followRedirects( true )
.cookies( HandleSession.COOKIES )
.data( postData )
.header( "X-Requested-With", "XMLHttpRequest" )
.method( Met )
.timeout( 10000 )
.execute();
Util.log.finest( tUri );
}
catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return res == null ? null : res.body();
}
错误在这一行:
.header( "X-Requested-With", "XMLHttpRequest" )
它说:
类型连接的方法头(字符串、字符串)未定义。KeyVal
但是jsoup文档说,此方法可用于以下参数:
我已经在jsoup的前一个版本中使用了这段代码
有什么问题吗?在Jsoup 1.9.2中,必须使用.requestBody而不是.data来设置请求正文。很抱歉,没有看到它。Ah,在Jsoup 1.9.2中,必须使用.requestBody而不是.data来设置请求正文。很抱歉,我没有看到。你应该加上这个作为答案