jsf和javascript,是不兼容的?

时间:2013-02-11 16:07:32

标签: javascript jsf

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

CODE:

> <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>

ERROR:

  

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>

1 个答案:

答案 0 :(得分:2)

Facelets是一种基于XML的视图技术。 XML中的<>reserved characters,表示元素的开头和结尾。但是,您尝试将它作为JavaScript字符串变量的一部分输出普通香草。您需要将其表示为&lt;&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]> conditional comments are rendered HTML-escaped in Facelets