首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >URL: http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd的服务器返回java.io.IOException响应代码503

URL: http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd的服务器返回java.io.IOException响应代码503
EN

Stack Overflow用户
提问于 2010-03-24 02:27:39
回答 2查看 5.1K关注 0票数 5

在以下代码中:

代码语言:javascript
复制
private Document transformDoc(Source source) throws TransformerException, IOException {
    TransformerFactory factory = TransformerFactory.newInstance();

    Transformer transformer =
            factory.newTransformer(new StreamSource(xsltResource.getInputStream()));
    JDOMResult result = new JDOMResult();
    transformer.transform(source, result);
    return result.getDocument();
}

我得到了这个例外:

代码语言:javascript
复制
java.io.IOException: Server returned HTTP response code: 503 for URL: http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd

我通过xsl转换的XHTML是:

代码语言:javascript
复制
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
  <title>Terms and Conditions</title>
</head>
<body>
  <div>Test Content</div>
</body>
</html>

我如何阻止xalan变压器给家里打电话?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2010-03-24 02:35:54

This post from the Xalan-J mailing list建议,“正确的方法”是您自己配置底层的Source/Reader来禁用验证。

票数 1
EN

Stack Overflow用户

发布于 2010-03-24 02:38:51

在解析器中禁用DTD解析(特定于解析器)或设置空的实体解析器。

http://www.jdom.org/docs/faq.html#a0350复制

代码语言:javascript
复制
public class NoOpEntityResolver implements EntityResolver {
  public InputSource resolveEntity(String publicId, String systemId) {
    return new InputSource(new StringBufferInputStream(""));
  }
}

// Then in the builder...

builder.setEntityResolver(new NoOpEntityResolver());
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/2502581

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档