我尝试使用包含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" ?>
有什么想法吗?
编辑:taglibs的版本为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>
答案 0 :(得分:1)
实际上,web.xml中的jsp-config部分没用,是导致问题的原因。没有它,一切都很好。我仍然不明白为什么问题由XML解析异常表达,因为这里的每个XML都是格式良好的,应该解析没有任何问题。错误本身就是误导。