Class ScriptTemplateView
java.lang.Object
org.springframework.web.reactive.result.view.AbstractView
org.springframework.web.reactive.result.view.AbstractUrlBasedView
org.springframework.web.reactive.result.view.script.ScriptTemplateView
- All Implemented Interfaces:
- Aware, BeanNameAware, InitializingBean, ApplicationContextAware, View
An 
AbstractUrlBasedView subclass designed to run any template library
based on a JSR-223 script engine.
If not set, each property is auto-detected by looking up a single
ScriptTemplateConfig bean in the web application context and using
it to obtain the configured properties.
The Nashorn JavaScript engine requires Java 8+ and may require setting the
sharedEngine property to false in order to run properly. See
ScriptTemplateConfigurer.setSharedEngine(Boolean) for more details.
- Since:
- 5.0
- Author:
- Sebastien Deleuze, Juergen Hoeller
- See Also:
- 
Field SummaryFields inherited from class AbstractViewlogger, REQUEST_DATA_VALUE_PROCESSOR_BEAN_NAMEFields inherited from interface ViewBINDING_CONTEXT_ATTRIBUTE
- 
Constructor SummaryConstructorsConstructorDescriptionConstructor for use as a bean.ScriptTemplateView(String url) Create a new ScriptTemplateView with the given URL.
- 
Method SummaryModifier and TypeMethodDescriptionprotected ScriptTemplateConfigbooleancheckResourceExists(Locale locale) Check whether the resource for the configured URL actually exists.protected ScriptEnginecreateEngineFromName(String engineName) protected ScriptEnginegetResource(String location) protected StringgetTemplate(String path) protected voidloadScripts(ScriptEngine engine) protected reactor.core.publisher.Mono<Void> renderInternal(Map<String, Object> model, @Nullable MediaType contentType, ServerWebExchange exchange) Subclasses must implement this method to actually render the view.voidSet the ApplicationContext that this object runs in.voidsetEngine(ScriptEngine engine) SeeScriptTemplateConfigurer.setEngine(ScriptEngine)documentation.voidsetEngineName(String engineName) SeeScriptTemplateConfigurer.setEngineName(String)documentation.voidsetEngineSupplier(Supplier<ScriptEngine> engineSupplier) SeeScriptTemplateConfigurer.setEngineSupplier(Supplier)documentation.voidsetRenderFunction(String functionName) SeeScriptTemplateConfigurer.setRenderFunction(String)documentation.voidsetRenderObject(String renderObject) SeeScriptTemplateConfigurer.setRenderObject(String)documentation.voidsetResourceLoaderPath(String resourceLoaderPath) SeeScriptTemplateConfigurer.setResourceLoaderPath(String)documentation.voidsetScripts(String... scripts) SeeScriptTemplateConfigurer.setScripts(String...)documentation.voidsetSharedEngine(Boolean sharedEngine) SeeScriptTemplateConfigurer.setSharedEngine(Boolean)documentation.Methods inherited from class AbstractUrlBasedViewafterPropertiesSet, getUrl, resourceExists, setUrl, toStringMethods inherited from class AbstractViewcreateRequestContext, formatViewName, getApplicationContext, getBeanName, getDefaultCharset, getModelAttributes, getRequestContextAttribute, getRequestDataValueProcessor, getSupportedMediaTypes, obtainApplicationContext, render, resolveAsyncAttributes, setBeanName, setDefaultCharset, setRequestContextAttribute, setSupportedMediaTypesMethods inherited from class Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface ViewisRedirectView
- 
Constructor Details- 
ScriptTemplateViewpublic ScriptTemplateView()Constructor for use as a bean.- See Also:
 
- 
ScriptTemplateViewCreate a new ScriptTemplateView with the given URL.
 
- 
- 
Method Details- 
setEngineSeeScriptTemplateConfigurer.setEngine(ScriptEngine)documentation.
- 
setEngineSupplierSeeScriptTemplateConfigurer.setEngineSupplier(Supplier)documentation.- Since:
- 5.2
 
- 
setEngineNameSeeScriptTemplateConfigurer.setEngineName(String)documentation.
- 
setScriptsSeeScriptTemplateConfigurer.setScripts(String...)documentation.
- 
setRenderObjectSeeScriptTemplateConfigurer.setRenderObject(String)documentation.
- 
setRenderFunctionSeeScriptTemplateConfigurer.setRenderFunction(String)documentation.
- 
setResourceLoaderPathSeeScriptTemplateConfigurer.setResourceLoaderPath(String)documentation.
- 
setApplicationContextDescription copied from interface:ApplicationContextAwareSet the ApplicationContext that this object runs in. Normally this call will be used to initialize the object.Invoked after population of normal bean properties but before an init callback such as InitializingBean.afterPropertiesSet()or a custom init-method. Invoked afterResourceLoaderAware.setResourceLoader(ResourceLoader),ApplicationEventPublisherAware.setApplicationEventPublisher(ApplicationEventPublisher)andMessageSourceAware, if applicable.- Specified by:
- setApplicationContextin interface- ApplicationContextAware
- Overrides:
- setApplicationContextin class- AbstractView
- Parameters:
- context- the ApplicationContext object to be used by this object
- See Also:
 
- 
getEngine
- 
createEngineFromName
- 
loadScripts
- 
getResource
- 
autodetectViewConfig- Throws:
- BeansException
 
- 
checkResourceExistsDescription copied from class:AbstractUrlBasedViewCheck whether the resource for the configured URL actually exists.- Specified by:
- checkResourceExistsin class- AbstractUrlBasedView
- Parameters:
- locale- the desired Locale that we're looking for
- Returns:
- falseif the resource exists- falseif we know that it does not exist
- Throws:
- Exception- if the resource exists but is invalid (for example, could not be parsed)
 
- 
renderInternalprotected reactor.core.publisher.Mono<Void> renderInternal(Map<String, Object> model, @Nullable MediaType contentType, ServerWebExchange exchange) Description copied from class:AbstractViewSubclasses must implement this method to actually render the view.- Specified by:
- renderInternalin class- AbstractView
- Parameters:
- model- combined output Map (never- null), with dynamic values taking precedence over static attributes
- contentType- the content type selected to render with, which should match one of the supported media types
- exchange- current exchange
- Returns:
- a Monothat represents when and if rendering succeeds
 
- 
getTemplate- Throws:
- IOException
 
 
-