渲染和响应自定义gson的不同(均为错误)输出 [英] Different (both bad) output for render and respond custom gson
问题描述
我使用Grails 3.2.3,并在 grails-app / views / training 中创建了自己的视图: _short-training.gson
import com.example.trainings.Training
model {
训练训练
}
json g.render(训练,[includes:['id','name']])
short-index.gson
import com.example.trainings.Training
model {
Iterable< Training> trainingList
}
json tmpl.'short-training'(trainingList?:[])
$ b $控制器中的b
我尝试了两种不同的方法,但是其中没有一个正在工作。都返回200状态,而不是我收到的6个训练实例:
render(view:short-index,model:[ trainingList:section.trainings])
[] 训练在短指数.gson ,同时使用 render ,但不会进一步传递。 响应根本不通过培训。我缺少什么? 替换 第一个参数可以用来指定模型变量名称 I'm using Grails 3.2.3 and created own views in grails-app/views/training: in _short-training.gson in short-index.gson in controller I tried two different approaches but noone of them is working. Both return 200 status but instead of 6 training instances I received: [null,null,null,null,null,null] [] it seems that trainings are visible in short-index.gson while used render but are not passed further. respond do not pass trainings at all. what am I missing? Replace With The first argument can be used to specify the model variable name 这篇关于渲染和响应自定义gson的不同(均为错误)输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
回复section.trainings,[status:OK,view:short-index]
json tmpl.'short-training'(trainingList?:[])
json tmpl.'short-training'(training,trainingList?:[])
import com.example.trainings.Training
model {
Training training
}
json g.render(training, [includes:['id', 'name']])
import com.example.trainings.Training
model {
Iterable<Training> trainingList
}
json tmpl.'short-training'(trainingList ?: [])
render(view: "short-index", model: [trainingList: section.trainings])
respond section.trainings, [status: OK, view:"short-index"]
json tmpl.'short-training'(trainingList ?: [])
json tmpl.'short-training'("training", trainingList ?: [])