gpt4 book ai didi

java - 确定 Grails 是字符串数组还是字符串数组

转载 作者:行者123 更新时间:2023-12-02 04:04:59 27 4
gpt4 key购买 nike

我试图弄清楚我拥有的一个数组是否有多个与其关联的字符串,或者它是否只是一个字符数组(字符串)。现在,如果我输入单数 ID 1234,我将得到一个 1,2,3,4 的数组,但如果我说有两个 ID 12 和 34,该数组将返回 12、34。当它应该总是一个字符串数组?

<div class="area">
<h2>Select all people who will be Traveling</h2>
<div>
<g:if test="${disabled=='false'}">
<g:select name="selector" class="claim" value="None" from="${fullList}" optionKey="studentID" optionValue="${{it.firstName + ' ' + it.lastName}}" noSelection="${['null':' ']}" disabled="${disabled}"/>
<g:if test="${tripInstance?.student!= null }">
<g:each var="i" in="${(0..<tripInstance?.student?.length) }">
<div>
<input class='field' name='Name' readonly type='text' value='${fullList.firstName[(tripInstance?.student[i]).toInteger()]} ${fullList.lastName[(tripInstance?.student[i]).toInteger()]}'/>
<input class='field' name='student' readonly type='hidden' value='${tripInstance?.student[i]}'/>
<label class='removeEdit fakeLink'> Remove</label>
</div>
</g:each>
</g:if>
</g:if>

<g:if test="${disabled=='true'}">
<g:if test="${tripInstance?.student!= null }">
<g:each var="i" in="${(0..<tripInstance?.student?.size()) }">
<div>
<input class='field' name='student' readonly disabled="${disabled}" type='text' value='${tripInstance?.student[i]}'/>
</div>
</g:each>
</g:if>
</g:if>
</div>
</div>

我尝试根据类(class)进行检查。我无法根据大小进行检查,因为字符串有大小,字符串数组也有大小。它是一个字符串数组而不是 Int 数组,因为代码的其他部分希望它采用这种格式。希望我没有忽略一些简单的事情。

最佳答案

Grails 在 params 对象上提供了一种方便的方法,以始终返回一个列表,而不是可能迭代单个字符串。它被方便地称为 list():

def ids = params.list('ids')

可以在 Simple Type Converters 下的文档中找到它.

关于java - 确定 Grails 是字符串数组还是字符串数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34403618/

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