gpt4 book ai didi

grails - 如何在gsp/groovy中获取检查项目

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

我有类似于下面提到的代码。

<g:each in="${Accounts}" var="account">
<li>
<g:hiddenField name="id" value="${account.id}" />
<g:hiddenField name="memberId" value="${account.memberId}" />
<g:hiddenField name="accountType" value="${account.type}" />
<label><input type="checkbox" />${member.name}</label>
</li>
</g:each>

在我的groovy Controller 中,我试图访问用户检查的帐户列表。

有人可以帮助我如何在我的 Controller “params”中获取已检查的项目

谢谢。

最佳答案

GSP:

  <g:form controller="some" action="updateAccountIds">
<g:each in="${Accounts}" var="account">
...
<label><g:checkBox name="checkedAccount" value="${account.id}"/>${member.name}</label>
</g:each>
</g:form>

Controller Action :
def updateAccountIds(){
def ids = params.list 'checkedAccount'
log.info "checked = $ids"

doOtherStuff()
}

关于grails - 如何在gsp/groovy中获取检查项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59825080/

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