Summary
- Grails 的 Controller 创建一个完整的响应给浏览器。
render :action_name
在同一个 Controller 中可以直接指定 action 名字。
render view: "/index"
响应为同一个 Controller 的index action。
render(view: "/index")"
响应为同一个 Controller 的index action。
render "widgets/show"
响应为其他 Controller 的页面。
render jsonOutput.prettyPrint(jsonRes)
直接响应 Json 字符串。
Demo
// 过滤数据,然后返回一个model包含provinceList、provinceTotal、filterParams、params对象。
render(view: 'index',
model: [provinceList : filterPaneService.filter(params, Province),
provinceTotal: filterPaneService.count(params, Province),
filterParams : FilterPaneUtils.extractFilterParams(params),
params : params])