簡體   English   中英

如何在Grails中顯示選擇標簽

[英]How to display a select tag in grails

我已經在form.gsp頁面中輸入了此標簽以顯示select但它不起作用。您能幫我找到我遇到的錯誤嗎?

    <div class="fieldcontain ${hasErrors(bean: userInstance, field: 'role', 'error')} required">
        <label for="role">
            <g:message code="user.role.label" default="Role" />
            <span class="required-indicator">*</span>
        </label>
        <g:select id="role" name="role.id" from="${taskmanagement1.secu.Role.list()}" optionKey="id" required="" value="${userInstance?.role?.id}" class="many-to-one"/>        
    </div>

注意:我正在使用Spring Security生成的Role&User域類。

您可以嘗試一下嗎,我沒有測試過,但認為可以

<g:select name="role.id" from="${taskmanagement1.secu.Role.list()}" optionKey="id" value="${userInstance.role*.id}" /> 

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM