在<classlib>行上的web.xml中获取org.xml.sax.SAXParseException

时间:2016-10-06 11:23:33

标签: java xml spring

我想使用jstl标记库,因为我在web.xml中包含了标记

但它在启动apache tomcat服务器时显示以下异常。

SEVERE: Begin event threw exception
java.lang.IllegalArgumentException: taglib definition not consistent with specification version
    at org.apache.catalina.startup.TaglibLocationRule.begin(WebRuleSet.java:1274)
    at org.apache.tomcat.util.digester.Digester.startElement(Digester.java:1276)
    ......
Oct 06, 2016 4:31:04 PM org.apache.catalina.startup.ContextConfig parseWebXml
SEVERE: Parse error in application web.xml file at jndi:/localhost/SpringExceptionHandling/WEB-INF/web.xml
org.xml.sax.SAXParseException; systemId: jndi:/localhost/SpringExceptionHandling/WEB-INF/web.xml; lineNumber: 33; columnNumber: 13; Error at (33, 13) : taglib definition not consistent with specification version
    at org.apache.tomcat.util.digester.Digester.createSAXException(Digester.java:2687)
Caused by: java.lang.IllegalArgumentException: taglib definition not consistent with specification version
    at org.apache.catalina.startup.TaglibLocationRule.begin(WebRuleSet.java:1274)
    at org.apache.tomcat.util.digester.Digester.startElement(Digester.java:1276)
    ... 

它的说法“ taglib定义与规范版本不一致” 如何查看版本

.. web.xml文件的一部分

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"

    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-app_3_0.xsd"
   version="3.0">


    <taglib>
    <taglib-uri>http://java.sun.com/jstl/core</taglib-uri>
    <taglib-location>/WEB-INF/tld/c.tld</taglib-location>
  </taglib>

2 个答案:

答案 0 :(得分:0)

xsi:schemaLocation - url“http://java.sun.com/xml/ns/j2ee web-app_3_0.xsd”不包含架构..尝试“http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd

答案 1 :(得分:0)

web-app_3_0.xsd类型与web-app_2_5.xsd不同,请参见: jsp_2_2.xsd 定义为通过以下链接链接的jsp-configType: web-common_3_0.xsd 对于<taglib>的定义:

<jsp-config>
  <taglib>
    <taglib-uri>http://java.sun.com/jstl/core</taglib-uri>
    <taglib-location>/WEB-INF/tld/c.tld</taglib-location>
  </taglib>     
</jsp-config>