0

我尝试使用包含 taglib 的 jar 文件。我收到“prolog 中不允许内容”错误(在下面的堆栈跟踪中使用法语):

sept. 12, 2013 3:52:49 PM org.apache.catalina.startup.TldConfig tldScanWebXml
Avertissement: Failed to process TLD with path [taglib-welcom-uri] and URI [/WEB-INF/lib/welcom-2.6.13-SNAPSHOT.jar]
java.io.IOException: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Contenu non autorisé dans le prologue.
    at org.apache.catalina.startup.TldConfig.tldScanStream(TldConfig.java:547)
    at org.apache.catalina.startup.TldConfig.tldScanWebXml(TldConfig.java:357)
    at org.apache.catalina.startup.TldConfig.execute(TldConfig.java:271)
    at org.apache.catalina.startup.TldConfig.lifecycleEvent(TldConfig.java:569)
    at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5322)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1559)
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1549)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
    at java.lang.Thread.run(Thread.java:722)
Caused by: org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1; Contenu non autorisé dans le prologue.
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:198)
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:177)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:441)
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:368)
    at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1388)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:996)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:607)
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:488)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:835)
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:764)
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:123)
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1210)
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:568)
    at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1537)
    at org.apache.catalina.startup.TldConfig.tldScanStream(TldConfig.java:544)
    ... 14 more

我的 jar 文件名为 welcom.jar 在 META-INF 中包含一个 welcom.tld 文件。我将此添加到我的 tomcat 的 web.xml 中:

<jsp-config>
    <taglib>
        <taglib-uri>taglib-welcom-uri</taglib-uri>
        <taglib-location>/WEB-INF/lib/welcom.jar</taglib-location>
    </taglib>
</jsp-config>

我看不出 tld 文件有什么问题,它在其他项目中使用没有任何问题。它以 ISO-8859-1 编码,这就是文件序言中指示的内容:

<?xml version="1.0" encoding="ISO-8859-1" ?>

任何想法?

编辑:标签库的版本是 1.2。有关更多信息,请查看 tld 文件的标头:

<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE taglib
  PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN"
  "http://java.sun.com/dtd/web-jsptaglibrary_1_2.dtd">
<taglib>
  <tlib-version>2.6</tlib-version>
  <jsp-version>1.2</jsp-version>
  <short-name>af</short-name>

  ...

</taglib>
4

1 回答 1

1

实际上,web.xml 中的 jsp-config 部分没有用,是问题的原因。没有它一切正常。我仍然不明白为什么问题会通过 XML 解析异常来表达,因为这里的每个 XML 格式都很好,应该毫无问题地解析。错误本身非常具有误导性。

于 2013-09-17T09:22:57.210 回答