2014-10-03 70 views

回答

0

一旦您的模型中的bookList针对您的GSP,这样做是微不足道的。

假设一个控制器的动作是这样的:

class MyController { 
    def index() { 
    def bookList = Book.getAll() 
    render(view: 'index', model: [bookList: bookList]) 
    } 
} 

和域这样的:

class Book { 
    String title 
} 

您可以使用g:select标签在你的GSP这样使它:

<g:select from="${bookList}" optionKey="id" optionValue="title" />