/** * Prepare the model to render. * @param model a Map with name Strings as keys and corresponding model * objects as values (Map can also be {@code null} in case of empty model) * @param contentType the content type selected to render with which should * match one of the {@link #getSupportedMediaTypes() supported media types}. * @param exchange the current exchange * @return {@code Mono} to represent when and if rendering succeeds */ @Override public Mono<Void> render(@Nullable Map<String, ?> model, @Nullable MediaType contentType, ServerWebExchange exchange) { if (logger.isDebugEnabled()) { logger.debug(exchange.getLogPrefix() + "View " + formatViewName() + ", model " + (model != null ? model : Collections.emptyMap())); } if (contentType != null) { exchange.getResponse().getHeaders().setContentType(contentType); } return getModelAttributes(model, exchange).flatMap(mergedModel -> { // Expose RequestContext? if (this.requestContextAttribute != null) { mergedModel.put(this.requestContextAttribute, createRequestContext(exchange, mergedModel)); } return renderInternal(mergedModel, contentType, exchange); }); }
/** * Prepare the model to render. * @param model Map with name Strings as keys and corresponding model * objects as values (Map can also be {@code null} in case of empty model) * @param contentType the content type selected to render with which should * match one of the {@link #getSupportedMediaTypes() supported media types}. * @param exchange the current exchange * @return {@code Mono} to represent when and if rendering succeeds */ @Override public Mono<Void> render(Map<String, ?> model, MediaType contentType, ServerWebExchange exchange) { if (logger.isTraceEnabled()) { logger.trace("Rendering view with model " + model); } if (contentType != null) { exchange.getResponse().getHeaders().setContentType(contentType); } Map<String, Object> mergedModel = getModelAttributes(model, exchange); // Expose RequestContext? if (this.requestContextAttribute != null) { mergedModel.put(this.requestContextAttribute, createRequestContext(exchange, mergedModel)); } return renderInternal(mergedModel, contentType, exchange); }