在 grails gsp 模板中,如何使用服务器端注释而不导致 sitemesh 抛出错误?
当我在 gsp 模板中使用标准 jsp 注释块时
<%-- some server-side comment --%>
,sitemesh 会抛出“意外标记”错误。我可以使用其他注释语法吗?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
以下对我有用
The following works for me
您缺少一个“%”符号。将其写为:
You are missing a '%' sign. Write it as :
之前的答案(以及问题本身)有些混乱,我希望一开始就向我解释。 .gsp 上有几种类型的服务器端注释。
因此,在 .gsp 文档中,服务器端注释如下:
file: _myTemplate.gsp
(Grails 2.5.5)
There's a little confusion among previous answers (and the question itself) that I wish was explained to me at first. There are a few types of server side comments on a .gsp.
So within the .gsp document Server side comments go as follow:
file: _myTemplate.gsp
(Grails 2.5.5)
最初的问题是询问如何注释掉 GSP 文件中的任何内容。唯一对我有用的是
<%-- some code to comment out --%>
,其他答案将不起作用,特别是如果被注释的代码是 grails 标签。 %{ 和 <% 不起作用。
The original question was asking how to comment out anything in the GSP file. The only one that worked for me is
<%-- some code to comment out --%>
,the other answers won't work especially if the code being commented are grails tags. %{ and <% didn't work.
常规的 java 注释块就可以工作
A regular java comment block will work
如果您正在编写一个想要显示未解释的 grails g: 标记的 gsp,例如您希望 ...按原样显示在页面上,无需在服务器端进行解释,以下内容对我来说效果很好。
在开始和结束标记中,将 < 替换为 <
,例如
if you are writing a gsp that wants to display a uninterpreted grails g: tag, e.g. you want <g:link ... to appear as-is on the page, without being interpreted server-side, the following worked nicely for me.
In both the start and end tags, replace the < with <
e.g.
<g:link...>...</g:link> gets interpreted server-side and shows up in the page a link.
<g:link ...>...</g:link ...> shows up in the front-end page as <g:link...>...</g:link>
<%-- 服务器端代码 --%>
应该可以工作<%-- server side code --%>
should work