我有以下代码:
try{
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
/* Get the XMLReader of the SAXParser we created. */
XMLReader r = sp.getXMLReader();
//This handles the xml and populates the entries array
XMLHandler handler = new XMLHandler();
// register event handlers
r.setContentHandler(handler);
String url = "http://news.library.ryerson.ca/api/isbnsearch.php?isbn="+ISBN;
r.parse(url);
return handler.getEntries();
}
这段代码在大多数情况下都可以正常工作,但在某些情况下,用户可以输入一本具有 100 多个相关 ISBN 的热门书籍的 isbn(例如哈利波特)。发生这种情况时,XML 提要不会中断,但加载时间会更长(极端情况下可能长达 30 多秒)。当页面加载时,它永远不会断开连接,它只是需要时间加载。
有没有办法增加函数的超时时间?
谢谢