gpt4 book ai didi

grails - O_o注释行中的异常

转载 作者:行者123 更新时间:2023-12-02 14:17:23 25 4
gpt4 key购买 nike

我有这个:

<!--   <div class="fieldcontain ${hasErrors(bean: azafataInstance, field: 'localidad', 'error')} required" style="margin-left: 10px">-->
<!--<label for="localidad">Localidad</label> -->
<!--<g:if test="${params?.localidad }">-->
<!--<g:select id="localidad" title="${g.message(code: 'infoPersonal.localidad')}" name="localidad" value="${params?.localidad}" from="${[' ',params.localidad]}" noSelection="${['':message(code:'localidadSelect')]}" onClick="this.style.color='black'" onFocus="this.style.color='black'" style="max-width:168px" />-->
<!--</g:if>-->
<!--<g:else>-->
<!--<g:select id="localidad" title="${g.message(code: 'infoPersonal.localidad')}" name="localidad" value="${params?.localidad}" from="${['']}" noSelection="${['':message(code:'localidadSelect')]}" onClick="this.style.color='black'" onFocus="this.style.color='black'" style="max-width:168px" />-->
<!--</g:else>-->
<!--</div>-->

如您所见...注释行。我运行该项目,我得到了:
URI
/com.publidirecta.azafatas/azafataCertificada/registro_page
Class
org.codehaus.groovy.grails.web.taglib.exceptions.GrailsTagException
Message
Tag [else] cannot have non-whitespace characters directly preceding it.

Around line 95 of grails-app/views/azafataCertificada/registro.gsp

92:<!--<g:if test="${params?.localidad }">-->
93:<!--<g:select id="localidad" title="${g.message(code: 'infoPersonal.localidad')}" name="localidad" value="${params?.localidad}" from="${[' ',params.localidad]}" noSelection="${['':message(code:'localidadSelect')]}" onClick="this.style.color='black'" onFocus="this.style.color='black'" style="max-width:168px" />-->
94: <!--</g:if>-->
95: <!--<g:else>-->
96: <!--<g:select id="localidad" title="${g.message(code: 'infoPersonal.localidad')}" name="localidad" value="${params?.localidad}" from="${['']}" noSelection="${['':message(code:'localidadSelect')]}" onClick="this.style.color='black'" onFocus="this.style.color='black'" style="max-width:168px" />-->
97:<!--</g:else>-->
98:<!--</div>-->

Trace

Line | Method
->> 886 | runTask in java.util.concurrent.ThreadPoolExecutor$Worker
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
| 908 | run in ''
^ 680 | run . . in java.lang.Thread

Caused by GrailsTagException: Tag [else] cannot have non-whitespace characters directly preceding it.
->> 95 | runTask in /grails-app/views/azafataCertificada/registro.gsp

问题是,显然...
在一个体面的框架中,注释行怎么可能引发异常!

最佳答案

因为<!--在GSP中不是注释。

如您所见,GSP解析器将HTML样式的注释视为普通内容,从而可以生成包含HTML注释的输出,例如脚本标记内

<script type="text/javascript><!--
js goes here;
//--></script>

IE conditional comments
<!--[if IE 6]>
<script type="text/javascript" src="${resource(dir:'css', file:'ie6-fixup.js')}"></script>
<![endif]-->

GSP注释的语法是
<%-- this is commented out --%>

GSP解析器将忽略此类注释中的任何内容。

关于grails - O_o注释行中的异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14253762/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com