javax.faces.view.facelets.FaceletException:注释中不允许使用字符串" - "

ahm*_*l88 1 jsf comments facelets

当试图添加一个 TODO在Facelets文件中的一段JavaScript代码中注释时

<script type="text/javascript">
    <!--

    // TODO -- my comment
    function makeExecute() {                            

    }                       

    -->
</script>
Run Code Online (Sandbox Code Playgroud)

然后我面临一个例外:

javax.faces.view.facelets.FaceletException: Error Parsing /myScreen.xhtml: 
    Error Traced[line: 448] The string "--" is not permitted within comments.
        at com.sun.faces.facelets.compiler.SAXCompiler.doCompile(SAXCompiler.java:390)
        at com.sun.faces.facelets.compiler.SAXCompiler.doCompile(SAXCompiler.java:364)
        at com.sun.faces.facelets.compiler.Compiler.compile(Compiler.java:122)
Run Code Online (Sandbox Code Playgroud)

这是怎么造成的,我该如何解决?

Kon*_*kov 5

stacktrace几乎说出来:

注释中不允许使用字符串" - ".

根据定义:

注释声明以<!,后跟零或多个注释开头,后跟>.注释开始和结束--,并且不包含任何" - ".

要消除错误,只需--在注释中键入一个空格(或删除它).

// TODO - - my comment
Run Code Online (Sandbox Code Playgroud)