参考:

 

问题:

解析xml时,报找不到.dtd错误,从而解析错。

 

解决方法:

在使用builder解析之前,设置禁止校验dtd。

builder.setEntityResolver(
                new EntityResolver(){
                   public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException
                   {
                       return new InputSource(new StringBufferInputStream(""));   
//                       return null;//这个的效果仍然是从网络来抓取DTD来验证
                       }
                }
            );

 

相关文章:

  • 2021-12-09
  • 2022-12-23
  • 2022-12-23
  • 2021-07-12
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-11
猜你喜欢
  • 2022-12-23
  • 2021-06-29
  • 2022-12-23
  • 2022-12-23
  • 2021-10-23
  • 2022-02-14
  • 2022-12-23
相关资源
相似解决方案