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.
ScriptTemplateConfigurer, ScriptTemplateViewResolver
| Modifier and Type | Class and Description |
|---|---|
| private static class | ScriptTemplateView.
Key class for the |
| Modifier and Type | Field and Description |
|---|---|
| private Charset | |
| private static final Charset | |
| public static final String | DEFAULT_CONTENT_TYPE
Hides org. |
| private static final String | |
| private ScriptEngine | |
| private String | |
| private static final ThreadLocal | |
| private Supplier | |
| private String | |
| private String | |
| private String[] | |
| private volatile ScriptEngineManager | |
| private String[] | |
| private Boolean |
| Access | Constructor and Description |
|---|---|
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| protected ScriptTemplateConfig | |
| public boolean | checkResource(Locale
the desired Locale that we're looking for locale)Overrides org. Check whether the underlying resource that the configured URL points to actually exists. |
| protected ScriptEngine | |
| private ScriptEngine | |
| protected ScriptEngine | |
| protected Resource | |
| protected String | |
| protected void | initApplicationContext(ApplicationContext
the containing ApplicationContext context)Overrides org. Calls |
| protected void | |
| protected void | prepareResponse(HttpServletRequest
current HTTP request request, HttpServletResponse current HTTP response response)Overrides org. Prepare the given response for rendering. |
| protected void | renderMergedOutputModel(Map<String, Object>
combined output Map (never model, HttpServletRequest null),
with dynamic values taking precedence over static attributescurrent HTTP request request, HttpServletResponse current HTTP response response)Implements abstract org. Subclasses must implement this method to actually render the view. |
| public void | |
| public void | |
| public void | |
| public void | setEngineSupplier(Supplier<ScriptEngine> engineSupplier)
See |
| public void | setRenderFunction(String functionName)
See |
| public void | setRenderObject(String renderObject)
See |
| public void | setResourceLoaderPath(String resourceLoaderPath)
See |
| public void | |
| public void | setSharedEngine(Boolean sharedEngine)
See |
| charset | back to summary |
|---|---|
| private Charset charset
| |
| DEFAULT_CHARSET | back to summary |
|---|---|
| private static final Charset DEFAULT_CHARSET | |
| DEFAULT_CONTENT_TYPE | back to summary |
|---|---|
| public static final String DEFAULT_CONTENT_TYPE Hides org. The default content type for the view. | |
| DEFAULT_RESOURCE_LOADER_PATH | back to summary |
|---|---|
| private static final String DEFAULT_RESOURCE_LOADER_PATH | |
| engine | back to summary |
|---|---|
| private ScriptEngine engine
| |
| engineName | back to summary |
|---|---|
| private String engineName
| |
| enginesHolder | back to summary |
|---|---|
| private static final ThreadLocal<Map<Object, ScriptEngine>> enginesHolder | |
| engineSupplier | back to summary |
|---|---|
| private Supplier<ScriptEngine> engineSupplier
| |
| renderFunction | back to summary |
|---|---|
| private String renderFunction
| |
| renderObject | back to summary |
|---|---|
| private String renderObject
| |
| resourceLoaderPaths | back to summary |
|---|---|
| private String[] resourceLoaderPaths
| |
| scriptEngineManager | back to summary |
|---|---|
| private volatile ScriptEngineManager scriptEngineManager
| |
| scripts | back to summary |
|---|---|
| private String[] scripts
| |
| sharedEngine | back to summary |
|---|---|
| private Boolean sharedEngine
| |
| ScriptTemplateView | back to summary |
|---|---|
| public ScriptTemplateView() Constructor for use as a bean.
| |
| ScriptTemplateView | back to summary |
|---|---|
| public ScriptTemplateView(String url) Create a new ScriptTemplateView with the given URL.
| |
| autodetectViewConfig | back to summary |
|---|---|
| protected ScriptTemplateConfig autodetectViewConfig() throws BeansException | |
| checkResource | back to summary |
|---|---|
| public boolean checkResource(Locale locale) throws Exception Overrides org. Doc from org. Check whether the underlying resource that the configured URL points to actually exists. | |
| createEngineFromName | back to summary |
|---|---|
| protected ScriptEngine createEngineFromName(String engineName) | |
| createEngineFromSupplier | back to summary |
|---|---|
| private ScriptEngine createEngineFromSupplier() | |
| getEngine | back to summary |
|---|---|
| protected ScriptEngine getEngine() | |
| getResource | back to summary |
|---|---|
protected Resource getResource(String location)
| |
| getTemplate | back to summary |
|---|---|
| protected String getTemplate(String path) throws IOException | |
| initApplicationContext | back to summary |
|---|---|
| protected void initApplicationContext(ApplicationContext context) Overrides org. Doc from org. Calls
| |
| loadScripts | back to summary |
|---|---|
| protected void loadScripts(ScriptEngine engine) | |
| prepareResponse | back to summary |
|---|---|
| protected void prepareResponse(HttpServletRequest request, HttpServletResponse response) Overrides org. Doc from org. Prepare the given response for rendering. The default implementation applies a workaround for an IE bug when sending download content via HTTPS.
| |
| renderMergedOutputModel | back to summary |
|---|---|
| protected void renderMergedOutputModel(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception Implements abstract org. Doc from org. Subclasses must implement this method to actually render the view. The first step will be preparing the request: In the JSP case, this would mean setting model objects as request attributes. The second step will be the actual rendering of the view, for example including the JSP via a RequestDispatcher.
| |
| setCharset | back to summary |
|---|---|
| public void setCharset(Charset charset) See | |
| setEngine | back to summary |
|---|---|
| public void setEngine(ScriptEngine engine) See | |
| setEngineName | back to summary |
|---|---|
| public void setEngineName(String engineName) See | |
| setEngineSupplier | back to summary |
|---|---|
| public void setEngineSupplier(Supplier<ScriptEngine> engineSupplier) See
| |
| setRenderFunction | back to summary |
|---|---|
| public void setRenderFunction(String functionName) See | |
| setRenderObject | back to summary |
|---|---|
| public void setRenderObject(String renderObject) See | |
| setResourceLoaderPath | back to summary |
|---|---|
| public void setResourceLoaderPath(String resourceLoaderPath) See | |
| setScripts | back to summary |
|---|---|
| public void setScripts(String... scripts) See | |
| setSharedEngine | back to summary |
|---|---|
| public void setSharedEngine(Boolean sharedEngine) See | |
enginesHolder ThreadLocal.
Only used if scripts have been specified; otherwise, the
engineName String will be used as cache key directly.
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | equals(Object
the reference object with which to compare. other)Overrides java. Indicates whether some other object is "equal to" this one. |
| public int |
| engineName | back to summary |
|---|---|
| private final String engineName | |
| scripts | back to summary |
|---|---|
| private final String[] scripts | |
| EngineKey | back to summary |
|---|---|
| public EngineKey(String engineName, String[] scripts) | |
| equals | back to summary |
|---|---|
| public boolean equals(Object other) Overrides java. Doc from java. Indicates whether some other object is "equal to" this one.
The
An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes. | |
| hashCode | back to summary |
|---|---|
| public int hashCode() Overrides java. Doc from java. Returns a hash code value for this object. This method is
supported for the benefit of hash tables such as those provided by
The general contract of
| |