2013-03-25 35 views
2

在我的應用程序中,我使用JSTL。但是當我在Tomcat中部署我的應用程序時,我得到了錯誤。在org.xml.sax.SAXParseException中安裝JSTL結果:序言中不允許使用內容

SEVERE: Parse Fatal Error at line 1 column 1: Content is not allowed in prolog. 
org.xml.sax.SAXParseException: Content is not allowed in prolog. 
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195) 
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:174) 
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:388) 
    at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1414) 
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:1039) 
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648) 
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511) 
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808) 
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737) 
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119) 
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205) 
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522) 
    at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1537) 
    at org.apache.catalina.startup.TldConfig.tldScanStream(TldConfig.java:515) 
    at org.apache.catalina.startup.TldConfig.tldScanWebXml(TldConfig.java:328) 
    at org.apache.catalina.startup.TldConfig.execute(TldConfig.java:243) 
    at org.apache.catalina.startup.TldConfig.lifecycleEvent(TldConfig.java:540) 
    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:5161) 
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) 
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1566) 
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1556) 
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) 
    at java.util.concurrent.FutureTask.run(FutureTask.java:138) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) 
    at java.lang.Thread.run(Thread.java:662) 
Mar 25, 2013 3:36:55 PM org.apache.catalina.startup.TldConfig tldScanWebXml 
WARNING: Failed to process TLD with path [http://java.sun.com/jstl/core] and URI [/WEB-INF/lib/jstl-1.2.jar] 
java.io.IOException: org.xml.sax.SAXParseException: Content is not allowed in prolog. 
    at org.apache.catalina.startup.TldConfig.tldScanStream(TldConfig.java:518) 
    at org.apache.catalina.startup.TldConfig.tldScanWebXml(TldConfig.java:328) 
    at org.apache.catalina.startup.TldConfig.execute(TldConfig.java:243) 
    at org.apache.catalina.startup.TldConfig.lifecycleEvent(TldConfig.java:540) 
    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:5161) 
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150) 
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1566) 
    at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1556) 
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303) 
    at java.util.concurrent.FutureTask.run(FutureTask.java:138) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886) 
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908) 
    at java.lang.Thread.run(Thread.java:662) 
Caused by: org.xml.sax.SAXParseException: Content is not allowed in prolog. 
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:195) 
    at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.fatalError(ErrorHandlerWrapper.java:174) 
    at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(XMLErrorReporter.java:388) 
    at com.sun.org.apache.xerces.internal.impl.XMLScanner.reportFatalError(XMLScanner.java:1414) 
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(XMLDocumentScannerImpl.java:1039) 
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648) 
    at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511) 
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808) 
    at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737) 
    at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119) 
    at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205) 
    at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522) 
    at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1537) 
    at org.apache.catalina.startup.TldConfig.tldScanStream(TldConfig.java:515) 
    ... 14 more 

我的web.xml文件中有如下條目:

<jsp-config> 
    <taglib> 
     <taglib-uri>http://java.sun.com/jstl/core</taglib-uri> 
     <taglib-location>/WEB-INF/lib/jstl-1.2.jar</taglib-location> 
    </taglib> 
</jsp-config> 

在JSP中我有以下頁/標籤庫聲明:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> 
<%@taglib uri="http://www.springframework.org/tags" prefix="spring"%> 
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%> 
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>` 

這是怎麼造成的異常,我該如何解決它?

+0

您正在使用的Tomcat版本是什麼? – 2013-03-25 11:43:05

+0

你從哪裏讀到你應該使用''?我希望你不要把'roseindia.net'作爲一個可靠的資源?至少,將'roseindia.net'添加到您一生的Internet黑名單中。然後,請閱讀我們的'[jstl]'標籤wiki頁面以獲取正確的信息和說明。將鼠標放在問題下方顯示的'[jstl]'標籤上,直到出現黑框,然後單擊其中的* info *鏈接。它應該帶你到http://stackoverflow.com/tags/jstl/info。 – BalusC 2013-03-25 12:13:40

回答

2

remove從web.xml中

<taglib> 
    <taglib-uri>http://java.sun.com/jstl/core</taglib-uri> 
    <taglib-location>/WEB-INF/lib/jstl-1.2.jar</taglib-location> 
</taglib> 

下你不需要這個,因爲的Servlet 2.0規範了。而且,taglib-location用於指定* .tld文件的路徑。

+0

它工作。謝謝。 – 2013-03-25 12:42:46

0

此錯誤消息始終是由開始元素中的無效XML內容引起的。例如,在XML元素的開頭添加了一個小點「。」。

see here

+1

我明白了,但我的問題是我沒有定義這個XML。它是jar的一部分。我仍然收到這個錯誤。 – 2013-03-25 12:21:07

相關問題