cvc-complex-type.2.4.a错误解决方法

    技术2024-09-25  64

    在使用web.xml描述文件中指定对标签的引用时:

    <taglib>

    <taglib-uri>/demotag</taglib-uri>

    <taglib-location>/WEB-INF/tlds/mytag.tld</taglib-location>

    </taglib>

    出现了以下错误:

    cvc-complex-type.2.4.a: Invalid content was found starting with element 'taglib'.

    百度之,发现<taglib>是<jsp-config>的子元素,需要将其写在<jsp-config></jsp-config>之间。

    改为:

    <jsp-config>

    <taglib>

    <taglib-uri>/demotag</taglib-uri>

    <taglib-location>/WEB-INF/tlds/mytag.tld</taglib-location>

    </taglib>

    </jsp-config>

    之后解决。

    同时在此贴一下有关:J2EE WEB项目web.xml<jsp-config>标签使用方法 ,方便查询

    <jsp-config>下辖两个子标签:<taglib> 和 <jsp-property-group>。前者在JSP 1.2时就已经存在,而后者是JSP 2.0 中新增的标签。

    <jsp-property-group>标签主要有以下属性:

    1,<el-ignored>:若为true,表示不支持EL 语法;默认为false; 2,<scripting-invalid>:若为true,表示不支持<% scripting %>语法;默认false; 3,<page-encoding>:设定JSP 网页的编码;比较有用; 4,<url-pattern>:设定值所影响的范围,如:/CH2 或 /*.jsp;当前设置的有效范围,用的好的话能带来很大方便,与page-encoding组合使用貌似可以用来解决国际化的问题;

    jsp-property-group的所有属性: 1、<description>:设定的说明; 2、<display-name>:设定名称; 3、<url-pattern>:设定值所影响的范围,如:/CH2 或 /*.jsp; 4、<el-ignored>:若为true,表示不支持EL 语法; 5、<scripting-invalid>:若为true,表示不支持<% scripting %>语法; 6、<page-encoding>:设定JSP 网页的编码; 7、<include-prelude>:设置JSP 网页的抬头,扩展名为.jspf; 8、<include-coda>:设置JSP 网页的结尾,扩展名为.jspf。

    <jsp-config>配置参考:

    <jsp-config>         <taglib>         <taglib-uri>Taglib</taglib-uri>         <taglib-location>/WEB-INF/tlds/MyTaglib.tld</taglib-location>     </taglib>

        <jsp-property-group>         <description>Special property group for JSP Configuration JSP example.</description>         <display-name>JSPConfiguration</display-name>         <url-pattern>/jsp/* </url-pattern>         <el-ignored>true</el-ignored>         <page-encoding>GB2312</page-encoding>         <scripting-invalid>true</scripting-invalid>         <include-prelude>/include/prelude.jspf</include-prelude>         <include-coda>/include/coda.jspf</include-coda>     </jsp-property-group>

    </jsp-config>

    最新回复(0)