靜態定義 respond 方法使用的支援回應格式。
class BookController { static responseFormats = ['xml', 'json'] def show(Long id) { respond Book.get(id) } }
responseFormats 屬性用於定義控制器支援的回應格式,而 respond 方法會使用這些格式。respond 方法使用 內容協商 回應最合適的內容類型。請參閱 REST 支援 文件,以取得更多資訊。
responseFormats
respond