Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/templates/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Templates 在grails gsp模板中,如何使用服务器端注释而不引发sitemesh错误?_Templates_Grails_Gsp_Sitemesh - Fatal编程技术网

Templates 在grails gsp模板中,如何使用服务器端注释而不引发sitemesh错误?

Templates 在grails gsp模板中,如何使用服务器端注释而不引发sitemesh错误?,templates,grails,gsp,sitemesh,Templates,Grails,Gsp,Sitemesh,当我在gsp模板中使用标准jsp注释块时 <%-- some server-side comment --%> ,sitemesh抛出“意外令牌”错误。我还可以使用其他注释语法吗?常规java注释块可以使用 <% /* some server side comment */ %> 以下内容适合我 %{-- <div>hello</div> --}% %{--hello--}% 您缺少“%”符号。写为: <%-- some

当我在gsp模板中使用标准jsp注释块时

<%-- some server-side comment --%>    


,sitemesh抛出“意外令牌”错误。我还可以使用其他注释语法吗?

常规java注释块可以使用

<% /*  some server side comment */ %>

以下内容适合我

%{-- <div>hello</div> --}%
%{--hello--}%

您缺少“%”符号。写为:

<%-- some server-side comment --%>

最初的问题是如何注释GSP文件中的任何内容。唯一对我有用的是


其他答案将不起作用,尤其是当注释的代码是grails标记时{和如果您正在编写一个gsp,它想要显示一个不奇怪的grails g:tag,例如,您想要在前端页面显示为
应该起作用

之前的答案(以及问题本身)有点混淆首先,我向我解释了我的愿望。在.gsp上有几种类型的服务器端注释。 因此,在.gsp文档服务器端,注释如下:

<%@ page contentType="text/html; charset=UTF-8" %>
<html>
<head></head>
<body>
    <!-- the basic HTML comment (not on server side) -->
    <h1>Visible on client side</h1>

    <%-- GSP common comment (server side only) --%>
    %{-- GSP alternative approach (again, on server side only) --}%
    <g:if test="${true}">
        <h1>Invisible on client side, just in source code</h1>
    </g:if>

    <p>and the one asked for happens elsewhere, 
    whenever you write classic Groovy script</p>
    <g:set var="myTitle"/>
    <%
        myVar = 'comment'
        if(myVar.equals('comment')){
            /*Needs the classic Java comment, 
            this happens whether you're writing a simple .gsp 
            or any _template.gsp*/
            myTitle = "<h1>Visible on server side only</h1>".encodeAsRaw()
        }
    %>
    ${myTitle}

    <p>.gsp template does not modify comment behaviour</p>
    <g:render template="/templates/myTemplate" model="[:]"/>
</body>
</html>

在客户端可见
%{--GSP替代方法(同样,仅限于服务器端)--}%
客户端不可见,仅在源代码中可见
而被要求的那个发生在别处,
无论何时编写经典Groovy脚本


谢谢。错别字只是问题,而不是代码,问题已经解决。澄清一下,问题是Grails 1.3.7在gsp页面中它不是一个好方法。使用真正为gsp页面创建的%{--}%
<h2>Template</h2>

<!-- visible -->
<% invisible %>
%{-- invisible --}%
<% /*invisible*/ %>