文章引用ITEYE网站博主jeelee的文章
配置web.xml文件时,taglib标签报错,但不会影响程序的运行,web.xml 如下:
<web-app id="WebApp_ID" version="2.4"
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 http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<display-name>testSitemeshdisplay-name>
<filter>
<filter-name>sitemeshfilter-name>
<filter-class>com.opensymphony.module.sitemesh.filter.PageFilterfilter-class>
filter>
<filter-mapping>
<filter-name>sitemeshfilter-name>
<url-pattern>/*url-pattern>
filter-mapping>
<taglib>
<taglib-uri>sitemesh-decoratortaglib-uri>
<taglib-location>/WEB-INF/sitemesh-decorator.tldtaglib-location>
taglib>
<taglib>
<taglib-uri>sitemesh-pagetaglib-uri>
<taglib-location>/WEB-INF/sitemesh-page.tldtaglib-location>
taglib>
<welcome-file-list>
<welcome-file>index.jspwelcome-file>
welcome-file-list>
web-app>
其中的taglib标签加入后,eclipse报错,内容如下:
cvc-complex-type.2.4.a: Invalid content was found starting with element 'taglib'. One of '{"http://java.sun.com/xml/ns/j2ee":description, "http://java.sun.com/xml/ns/j2ee":display-name, "http://java.sun.com/xml/ns/j2ee":icon, "http://java.sun.com/xml/ns/j2ee":distributable, "http://java.sun.com/xml/ns/j2ee":context-param, "http://java.sun.com/xml/ns/j2ee":filter, "http://java.sun.com/xml/ns/j2ee":filter-mapping, "http://java.sun.com/xml/ns/j2ee":listener, "http://java.sun.com/xml/ns/j2ee":servlet, "http://java.sun.com/xml/ns/j2ee":servlet-mapping, "http://java.sun.com/xml/ns/j2ee":session-config, "http://java.sun.com/xml/ns/j2ee":mime-mapping, "http://java.sun.com/xml/ns/j2ee":welcome-file-list, "http://java.sun.com/xml/ns/j2ee":error-page, "http://java.sun.com/xml/ns/j2ee":jsp-config, "http://java.sun.com/xml/ns/j2ee":security-constraint, "http://java.sun.com/xml/ns/j2ee":login-config, "http://java.sun.com/xml/ns/j2ee":security-role, "http://java.sun.com/xml/ns/j2ee":env-entry, "http://java.sun.com/xml/ns/j2ee":ejb-ref, "http://java.sun.com/xml/ns/j2ee":ejb-local-ref, "http://java.sun.com/xml/ns/j2ee":service-ref, "http://java.sun.com/xml/ns/j2ee":resource-ref, "http://java.sun.com/xml/ns/j2ee":resource-env-ref, "http://java.sun.com/xml/ns/j2ee":message-destination-ref, "http://java.sun.com/xml/ns/j2ee":message-destination, "http://java.sun.com/xml/ns/j2ee":locale-encoding-mapping-list}' is expected.
解决方法有两个:
1、把
id="WebApp_ID" version="2.4"
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 http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
这句改成
<web-app >
解 释:在jsp2.0中,且2.4版的DTD验证中,初步估计是由于eclipse在部署时,未对web.xml进行一些校验,而jbuilder则进行了 校验,并除非不合法的描述符,而taglib描述符,正确写法是放到描述符 中。
2、在taglib外面加个jsp-config标签:
<jsp-config>
<taglib>
<taglib>
<taglib-uri>sitemesh-decorator</taglib-uri>
<taglib-location>/WEB-INF/sitemesh-decorator.tld</taglib-location>
</taglib>
<taglib>
<taglib-uri>sitemesh-page</taglib-uri>
<taglib-location>/WEB-INF/sitemesh-page.tld</taglib-location>
</taglib>
</jsp-config>
标签使用详解:
包括
和
两个子元素。
其中
元素在JSP 1.2时就已经存在;而
是JSP 2.0 新增的元素。
元素主要有八个子元素,它们分别为:
1.
:设定的说明;
2.
:设定名称;
3.
:设定值所影响的范围,如:/CH2 或 /*.jsp;
4.
:若为true,表示不支持EL 语法;
5.
:若为true,表示不支持<% scripting %>语法;
6.
:设定JSP 网页的编码;
7.
:设置JSP 网页的抬头,扩展名为.jspf;
8.
:设置JSP 网页的结尾,扩展名为.jspf。