我正在尝试使用从 SQL 返回的一些行填充 grails 选择,但由于某种原因它无法正常工作。我有以下代码:
控制器:
import groovy.sql.Sql
class ClinicalRequirementsController {
static allowedMethods = [save: "POST", update: "POST", delete: "POST"]
def dataSource //injection of dataSource
def create() {
def db = new Sql(dataSource)
def terms = db.rows("""SELECT stvterm_code
FROM stvterm
WHERE stvterm_fa_proc_yr = (SELECT stvterm_fa_proc_yr
FROM stvterm, current_term
WHERE stvterm_code = current_term.cur_term)
ORDER BY stvterm_code ASC""")
[terms: terms]
db.close()
[clinicalRequirementsInstance: new ClinicalRequirements(params)]
}
}
普惠制选择:
<g:select name="insuranceSemesterVerified" from="${terms}" required="" value="${clinicalRequirementsInstance?.insuranceSemesterVerified}" valueMessagePrefix="clinicalRequirements.insuranceSemesterVerified"/>
我很困惑。希望有人可以指出我出了什么问题。我已经在别处验证了针对数据库的查询。