您的位置:程序门 -> java -> web 开发



xml 


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


xml
发表于:2008-01-09 22:09:17 楼主
<?xml   version="1.0"   encoding="utf-8"?>
<web-app   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"> //不一样的


    <servlet>
                <servlet-name> dispatcher </servlet-name>
                <servlet-class> mypack.dispatcherservlet </servlet-class>
                <load-on-startup> 1 </load-on-startup>
      </servlet>

      <servlet-mapping>
                <servlet-name> dispatcher </servlet-name>
                <url-pattern> /dispatcher </url-pattern>
      </servlet-mapping>


  <taglib> (这里为什么个有大红叉)
        <taglib-uri> /mytaglib </taglib-uri>
        <taglib-location> /web-inf/mytaglib.tld </taglib-location>
    </taglib>

</web-app>
但下面这些为什么对的:

<?xml   version="1.0"   encoding="iso-8859-1"?>

<!doctype   web-app   public
    '-//sun   microsystems,   inc.//dtd   web   application   2.3//en'
    'http://java.sun.com/j2ee/dtds/web-app_2_3.dtd'> //不一样的

<web-app>

    <servlet>
                <servlet-name> dispatcher </servlet-name>
                <servlet-class> mypack.dispatcherservlet </servlet-class>
                <load-on-startup> 1 </load-on-startup>
      </servlet>

      <servlet-mapping>
                <servlet-name> dispatcher </servlet-name>
                <url-pattern> /dispatcher </url-pattern>
      </servlet-mapping>


  <taglib>
        <taglib-uri> /mytaglib </taglib-uri>
        <taglib-location> /web-inf/mytaglib.tld </taglib-location>
    </taglib>

</web-app>
这两个只是我标记的了地方不一样,问题在哪!是标记那有问题?但上面一个我是在myeclispe中自己生成的,只是加个 <taglib> 就不对,web中有 <taglib> 这个标签的啊!
发表于:2008-01-09 22:28:561楼 得分:0
web-app       version="2.4"      

      下边的是2.3
发表于:2008-01-09 22:55:322楼 得分:0
如2楼所述,xml   的   version   不一样,   validator   rule   也不一样  
发表于:2008-01-09 23:45:113楼 得分:0
2.4和2.3都应该对 <taglib> 支持吧!怎么会出错啊?请略详解!
发表于:2008-01-10 10:54:574楼 得分:0
我已经试过了,确实是2.4不支持 <taglib> 标签

下面是在myeclipse中的报错信息,楼主可以看一下:
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.
发表于:2008-01-10 12:24:345楼 得分:0
那在2.4版中是不有没办法用 <tablib> 了,有什么办法可用吗?
发表于:2008-01-10 13:52:246楼 得分:0
2.4中使用 <taglib> 的方法:

在 <taglib> 外面加上 <jsp-config>

    2.3中可以直接写:
   
xml code
<taglib> <taglib-uri> /mytaglib </taglib-uri> <taglib-location> /web-inf/mytaglib.tld </taglib-location> </taglib>


    2.4中要写成:
   
xml code
<jsp-config> <taglib> <taglib-uri> /mytaglib </taglib-uri> <taglib-location> /web-inf/mytaglib.tld </taglib-location> </taglib> </jsp-config>

   
发表于:2008-01-10 19:58:417楼 得分:0
谢谢了


快速检索

最新资讯
热门点击