在配置web.xml的时候,添加了标签,可是却提示错误,出了红叉,但是不影响 tag的使用,错误提示为: 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.
上网搜索一下解决办法如下:
发现问题出在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">
第一种方法: 删了这句(记得要保留<web-app>)红叉就不见了。
第二种方法:
保留不变,把<taglib></taglib>用<jsp-config></jsp-config>包括起来,一样不会提示错误。
有搜到这样的解释: 在jsp2.0中,且2.4版的DTD验证中,初步估计是由于eclipse在部署时,未对web.xml进行一些校验,而jbuilder则进行了校验,并除非不合法的描述符,而taglib描述符,正确写法是放到<jsp-config></jsp-config>描述符中。 相信是一样的原因。eclipse3.2开始也对web.xml做校验,所以提示错误。在eclipse3.1.2里没有提示错误。