0

我正在将 html 迁移到 jsf 文件,但脚本失败,该脚本在安装在 wamp 服务器中的 html 中工作。

代码:

> <h:head>
>         <meta charset="utf-8"/>
>         <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
>         <title></title>
>         <meta name="description" content=""/>
>         <meta name="viewport" content="width=device-width, initial-scale=1"/>
>         <link rel="stylesheet" href="../css/media-queries.css" media="screen" />
>         <script type="" src="../js/vendor/modernizr.2.6.2.min.js"></script>
>         <script type="" src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
>         <script type="text/javascript">window.jQuery || document.write('<script
> src="../js/vendor/jquery-1.8.0.min.js"><\/script>')</script> <!--  This is the line 21 -->
>         <script type="" src="../js/jquery.mobile.min.js"></script>
>         <script type="" src="../js/jquery.dataTables.min.js"></script>
>         <script type="" src="../js/jquery.formCharmer.js"></script>
>         <script type="">if(Modernizr.csstransitions){document.write('<link
> rel="stylesheet" href="../css/charmerAnimation.css"/>')}</script>
>         <!--[if (gte IE 6)&(lte IE 8)]>
>             <script src="../js/selectivizr.min.js"></script>
>         <![endif]-->
>         <!--[if lte IE 9]>
>             <script src="../js/css3-mediaqueries.js"></script>
>         <![endif]-->
>     </h:head>

错误:

HTTP 状态 500 - 解析错误 /content/contentA.xhtml:错误跟踪 [行:21] 元素的内容必须由数据标记或正确的格式组成。

这是 HTML 代码:

<head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <title></title>
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="stylesheet" href="../css/media-queries.css" media="screen" />
        <script src="../js/vendor/modernizr.2.6.2.min.js"></script>
        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
        <script>window.jQuery || document.write('<script src="../js/vendor/jquery-1.8.0.min.js"><\/script>')</script>
        <script src="../js/jquery.mobile.min.js"></script>
        <script src="../js/jquery.dataTables.min.js"></script>
        <script src="../js/jquery.formCharmer.js"></script>
        <script>if(Modernizr.csstransitions){document.write('<link rel="stylesheet" href="../css/charmerAnimation.css">')}</script>     
        <!--[if (gte IE 6)&(lte IE 8)]>
            <script src="../js/selectivizr.min.js"></script>
        <![endif]-->
        <!--[if lte IE 9]>
            <script src="../js/css3-mediaqueries.js"></script>
        <![endif]-->
    </head>
4

1 回答 1

2

Facelets 是一种基于 XML 的视图技术。<>是XML 中的保留字符,表示元素的开始和结束。但是,您尝试将其作为 JavaScript 字符串变量的一部分输出。您需要将它们表示为&lt;and &gt;

<script>window.jQuery || document.write('&lt;script src="../js/vendor/jquery-1.8.0.min.js"&gt;&lt;\/script&gt;')</script>

这同样适用于&代码中更下方的字符,它表示实体的开始。顺便说一句,一旦您解决了这个问题,您就遇到了 IE 条件注释的新问题,这里得到了回答:<!--[if IE]> 条件注释在 Facelets 中呈现 HTML 转义

于 2013-02-11T17:18:07.623 回答