首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

web.xml异常调试

2012-09-20 
web.xml错误调试声明:此文为转载的,感觉有用就收藏了。在做web项目时,web.xml的配置文件,这里列出出错的地

web.xml错误调试
声明:此文为转载的,感觉有用就收藏了。

在做web项目时,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" version="2.4"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee   http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<servlet>
   <servlet-name>DisplaySource</servlet-name>
   <display-name>DisplaySource</display-name>
   <description>display source of sample jsp pages</description>
   <servlet-class>com.telin.develop.displaytag.sample.DisplaySourceServlet</servlet-class>
</servlet>
<servlet-mapping>
   <servlet-name>DisplaySource</servlet-name>
   <url-pattern>*.source</url-pattern>
</servlet-mapping>

<taglib>
   <taglib-uri>displaytag</taglib-uri>
   <taglib-location>/WEB-INF/displaytag.tld</taglib-location>
</taglib>
</web-app>

出现错误,如下:
1).Severity and Description Path Resource Location Creation Time Id
cvc-complex-type.2.4.a: Invalid content was found starting with element 'display-name'.
One of '{"http://java.sun.com/xml/ns/j2ee":servlet-class,
"http://java.sun.com/xml/ns/j2ee":jsp-file}'
is expected. daiweihzdx/WebRoot/WEB-INF web.xml
2).Severity and Description Path Resource Location Creation Time Id
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.
        daiweihzdx/WebRoot/WEB-INF web.xml

下面列出解决办法
1)去掉:
   <display-name>DisplaySource</display-name>
   <description>display source of sample jsp pages</description>
2)把:
<taglib>
   <taglib-uri>displaytag</taglib-uri>
   <taglib-location>/WEB-INF/displaytag.tld</taglib-location>
</taglib>
放在:
<jsp-config></jsp-config>标签之中

分析:
出现错误的原因:通常是由于标签位置,标签DTD的校验规则所影响的,
所以上述问题还有如下解决办法

3).删除“http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd”即不采用该校验规则
4).把头文件中的“version="2.4"”改为“version="2.5"”
“http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd”改为“http://java.sun.com/xml/ns/j2ee/web-app_2_5.xsd”
即采用jsp2.5的校验规则

热点排行