解决taglib definition not consistent with specification version 错误

报错信息如下

org.xml.sax.SAXParseException; systemId: jndi:/localhost/NEWJZJK/WEB-INF/web.xml; lineNumber: 289; columnNumber: 10; Error at (289, 10) : taglib definition not consistent with specification version
at org.apache.tomcat.util.digester.Digester.createSAXException(Digester.java:2705)
at org.apache.tomcat.util.digester.Digester.createSAXException(Digester.java:2737)
at org.apache.tomcat.util.digester.Digester.startElement(Digester.java:1285)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1555)
at org.apache.catalina.startup.ContextConfig.parseWebXml(ContextConfig.java:1858)
at org.apache.catalina.startup.ContextConfig.webConfig(ContextConfig.java:1263)
at org.apache.catalina.startup.ContextConfig.configureStart(ContextConfig.java:889)
at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:386)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:117)
at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:90)
at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5479)
at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1574)
at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1564)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
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:1282)
... 25 more

1.问题描述

从tomcat 6 迁移到tomcat 7 时,运行web项目时出现"taglib definition not consistent with specification version"

从上面可以看出, 这是taglib的定义不符合规范版本的原因引起来的

2.解决办法

方式一

修改前(这个是在tomcat6中的配置)

 1     <taglib>
 2         <taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
 3         <taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
 4     </taglib>
 5     <taglib>
 6         <taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
 7         <taglib-location>/WEB-INF/struts-html.tld</taglib-location>
 8     </taglib>
 9     <taglib>
10         <taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>
11         <taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
12     </taglib>
13     <taglib>
14         <taglib-uri>/WEB-INF/struts-tiles.tld</taglib-uri>
15         <taglib-location>/WEB-INF/struts-tiles.tld</taglib-location>
16     </taglib>
17     <taglib>
18         <taglib-uri>/WEB-INF/struts-nested.tld</taglib-uri>
19         <taglib-location>/WEB-INF/struts-nested.tld</taglib-location>
20     </taglib>

 

修改后(这个是在tomcat7中的配置)

 1     <jsp-config>
 2         <taglib>
 3             <taglib-uri>/WEB-INF/struts-html.tld</taglib-uri>
 4             <taglib-location>/WEB-INF/struts-html.tld</taglib-location>
 5         </taglib>
 6         <taglib>
 7             <taglib-uri>/WEB-INF/struts-bean.tld</taglib-uri>
 8             <taglib-location>/WEB-INF/struts-bean.tld</taglib-location>
 9         </taglib>
10         <taglib>
11             <taglib-uri>/WEB-INF/struts-logic.tld</taglib-uri>
12             <taglib-location>/WEB-INF/struts-logic.tld</taglib-location>
13         </taglib>
14     </jsp-config>

 

方式二

修改前

1 <taglib>
2     <taglib-uri>/custom</taglib-uri>
3     <taglib-location>/WEB-INF/tld/custom.tld</taglib-location>
4 </taglib>

修改后

1 <!-- 自定义标签 -->
2 <jsp-config>
3     <taglib>
4     <taglib-uri>/custom</taglib-uri>
5     <taglib-location>/WEB-INF/tld/custom.tld</taglib-location>
6     </taglib>
7 </jsp-config>

 

posted @ 2018-09-05 17:11  爬行的乌龟  阅读(1765)  评论(0编辑  收藏  举报