类 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
- 所有已实现的接口:
Aware
,BeanNameAware
,InitializingBean
,ApplicationContextAware
,View
public class ScriptTemplateView extends AbstractUrlBasedView
AnAbstractUrlBasedView
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 tofalse
in order to run properly. SeeScriptTemplateConfigurer.setSharedEngine(Boolean)
for more details.- 从以下版本开始:
- 5.0
- 作者:
- Sebastien Deleuze, Juergen Hoeller
- 另请参阅:
ScriptTemplateConfigurer
,ScriptTemplateViewResolver
字段概要
从类继承的字段 org.springframework.web.reactive.result.view.AbstractView
logger, REQUEST_DATA_VALUE_PROCESSOR_BEAN_NAME
从接口继承的字段 org.springframework.web.reactive.result.view.View
BINDING_CONTEXT_ATTRIBUTE
构造器概要
构造器 构造器 说明 ScriptTemplateView()
Constructor for use as a bean.ScriptTemplateView(String url)
Create a new ScriptTemplateView with the given URL.
方法概要
从类继承的方法 org.springframework.web.reactive.result.view.AbstractUrlBasedView
afterPropertiesSet, getUrl, setUrl, toString
从类继承的方法 org.springframework.web.reactive.result.view.AbstractView
createRequestContext, formatViewName, getApplicationContext, getBeanName, getDefaultCharset, getModelAttributes, getRequestContextAttribute, getRequestDataValueProcessor, getSupportedMediaTypes, obtainApplicationContext, render, resolveAsyncAttributes, resolveAsyncAttributes, setBeanName, setDefaultCharset, setRequestContextAttribute, setSupportedMediaTypes
从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
从接口继承的方法 org.springframework.web.reactive.result.view.View
isRedirectView
构造器详细资料
ScriptTemplateView
public ScriptTemplateView()
Constructor for use as a bean.
ScriptTemplateView
public ScriptTemplateView(String url)
Create a new ScriptTemplateView with the given URL.
方法详细资料
setEngine
public void setEngine(ScriptEngine engine)
SeeScriptTemplateConfigurer.setEngine(ScriptEngine)
documentation.
setEngineSupplier
public void setEngineSupplier(Supplier<ScriptEngine> engineSupplier)
SeeScriptTemplateConfigurer.setEngineSupplier(Supplier)
documentation.- 从以下版本开始:
- 5.2
setEngineName
public void setEngineName(String engineName)
SeeScriptTemplateConfigurer.setEngineName(String)
documentation.
setSharedEngine
public void setSharedEngine(Boolean sharedEngine)
SeeScriptTemplateConfigurer.setSharedEngine(Boolean)
documentation.
setScripts
public void setScripts(String... scripts)
SeeScriptTemplateConfigurer.setScripts(String...)
documentation.
setRenderObject
public void setRenderObject(String renderObject)
SeeScriptTemplateConfigurer.setRenderObject(String)
documentation.
setRenderFunction
public void setRenderFunction(String functionName)
SeeScriptTemplateConfigurer.setRenderFunction(String)
documentation.
setResourceLoaderPath
public void setResourceLoaderPath(String resourceLoaderPath)
SeeScriptTemplateConfigurer.setResourceLoaderPath(String)
documentation.
setApplicationContext
public void setApplicationContext(@Nullable ApplicationContext context)
从接口复制的说明:ApplicationContextAware
Set 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(org.springframework.core.io.ResourceLoader)
,ApplicationEventPublisherAware.setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher)
andMessageSourceAware
, if applicable.- 指定者:
setApplicationContext
在接口中ApplicationContextAware
- 覆盖:
setApplicationContext
在类中AbstractView
- 参数:
context
- the ApplicationContext object to be used by this object- 另请参阅:
BeanInitializationException
getEngine
protected ScriptEngine getEngine()
createEngineFromName
protected ScriptEngine createEngineFromName(String engineName)
loadScripts
protected void loadScripts(ScriptEngine engine)
getResource
@Nullable protected Resource getResource(String location)
autodetectViewConfig
protected ScriptTemplateConfig autodetectViewConfig() throws BeansException
checkResourceExists
public boolean checkResourceExists(Locale locale) throws Exception
从类复制的说明:AbstractUrlBasedView
Check whether the resource for the configured URL actually exists.- 指定者:
checkResourceExists
在类中AbstractUrlBasedView
- 参数:
locale
- the desired Locale that we're looking for- 返回:
false
if the resource existsfalse
if we know that it does not exist- 抛出:
Exception
- if the resource exists but is invalid (e.g. could not be parsed)
renderInternal
protected reactor.core.publisher.Mono<Void> renderInternal(Map<String,Object> model, @Nullable MediaType contentType, ServerWebExchange exchange)
从类复制的说明:AbstractView
Subclasses must implement this method to actually render the view.- 指定者:
renderInternal
在类中AbstractView
- 参数:
model
- combined output Map (nevernull
), with dynamic values taking precedence over static attributescontentType
- the content type selected to render with, which should match one of the supported media typesexchange
- current exchange- 返回:
- a
Mono
that represents when and if rendering succeeds
getTemplate
protected String getTemplate(String path) throws IOException
- 抛出:
IOException