这是我的模板:
<tbody id="byCountry">
{% for dataFilm in film %}
<tr>
<td>{{Date}}</td>
<td>{{Title}}</td>
<td>{{MainActor}}</td>
</tr>
{% endfor %}
</tbody>
summary.onComplete(jsonObjectAsyncResult -> {
if (jsonObjectAsyncResult.succeeded()) {
JsonArray summaryArray = jsonObjectAsyncResult.result().getJsonArray("Films");
JsonObject filmInfo = new JsonObject();
for( int i = 0; i<summaryArray.size(); i++){
filmInfo.put("summaryArray",summaryArray)
.put("Date", summaryArray.getJsonObject(i).getString("Date"))
.put("Title", summaryArray.getJsonObject(i).getString("Title"))
.put("MainActor", summaryArray.getJsonObject(i).("MainActor"));
engine.render(filmInfo, "webroot/templates/films.peb", res ->{
if (res.succeeded()) {
routingContext.response()
.end(res.result());
} else {
routingContext.fail(res.cause());
}
});
这里的问题是当我尝试渲染时,只渲染第一部电影或最后一部电影,因为我必须用 engine.render 结束响应......知道我应该怎么做吗?