Search in sources :

Example 1 with ScriptTemplateConfigurer

use of org.springframework.web.reactive.result.view.script.ScriptTemplateConfigurer in project spring-framework by spring-projects.

the class ViewResolverRegistry method scriptTemplate.

/**
 * Register a script template view resolver with an empty default view name prefix and suffix.
 * <p><strong>Note</strong> that you must also configure script templating by
 * adding a {@link ScriptTemplateConfigurer} bean.
 * @since 5.0.4
 */
public UrlBasedViewResolverRegistration scriptTemplate() {
    if (!checkBeanOfType(ScriptTemplateConfigurer.class)) {
        throw new BeanInitializationException("In addition to a script template view resolver " + "there must also be a single ScriptTemplateConfig bean in this web application context " + "(or its parent): ScriptTemplateConfigurer is the usual implementation. " + "This bean may be given any name.");
    }
    ScriptRegistration registration = new ScriptRegistration();
    UrlBasedViewResolver resolver = registration.getViewResolver();
    if (this.applicationContext != null) {
        resolver.setApplicationContext(this.applicationContext);
    }
    this.viewResolvers.add(resolver);
    return registration;
}
Also used : BeanInitializationException(org.springframework.beans.factory.BeanInitializationException) UrlBasedViewResolver(org.springframework.web.reactive.result.view.UrlBasedViewResolver) ScriptTemplateConfigurer(org.springframework.web.reactive.result.view.script.ScriptTemplateConfigurer)

Aggregations

BeanInitializationException (org.springframework.beans.factory.BeanInitializationException)1 UrlBasedViewResolver (org.springframework.web.reactive.result.view.UrlBasedViewResolver)1 ScriptTemplateConfigurer (org.springframework.web.reactive.result.view.script.ScriptTemplateConfigurer)1