类 ScriptTemplateView
- java.lang.Object
- org.springframework.context.support.ApplicationObjectSupport
- org.springframework.web.context.support.WebApplicationObjectSupport
- org.springframework.web.servlet.view.AbstractView
- org.springframework.web.servlet.view.AbstractUrlBasedView
- org.springframework.web.servlet.view.script.ScriptTemplateView
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.- 从以下版本开始:
- 4.2
- 作者:
- Sebastien Deleuze, Juergen Hoeller
- 另请参阅:
ScriptTemplateConfigurer
,ScriptTemplateViewResolver
字段概要
字段 修饰符和类型 字段 说明 static String
DEFAULT_CONTENT_TYPE
从类继承的字段 org.springframework.context.support.ApplicationObjectSupport
logger
从接口继承的字段 org.springframework.web.servlet.View
PATH_VARIABLES, RESPONSE_STATUS_ATTRIBUTE, SELECTED_CONTENT_TYPE
构造器概要
构造器 构造器 说明 ScriptTemplateView()
Constructor for use as a bean.ScriptTemplateView(String url)
Create a new ScriptTemplateView with the given URL.
方法概要
从类继承的方法 org.springframework.web.servlet.view.AbstractUrlBasedView
afterPropertiesSet, getUrl, isUrlRequired, setUrl, toString
从类继承的方法 org.springframework.web.servlet.view.AbstractView
addStaticAttribute, createMergedOutputModel, createRequestContext, createTemporaryOutputStream, exposeModelAsRequestAttributes, generatesDownloadContent, getAttributesMap, getBeanName, getContentType, getRequestContextAttribute, getRequestToExpose, getStaticAttributes, isExposePathVariables, render, setAttributes, setAttributesCSV, setAttributesMap, setBeanName, setExposeContextBeansAsAttributes, setExposedContextBeanNames, setExposePathVariables, setRequestContextAttribute, setResponseContentType, writeToResponse
从类继承的方法 org.springframework.web.context.support.WebApplicationObjectSupport
getServletContext, getTempDir, getWebApplicationContext, initServletContext, isContextRequired, setServletContext
从类继承的方法 org.springframework.context.support.ApplicationObjectSupport
getApplicationContext, getMessageSourceAccessor, initApplicationContext, requiredContextClass, setApplicationContext
字段详细资料
DEFAULT_CONTENT_TYPE
public static final String DEFAULT_CONTENT_TYPE
- 另请参阅:
- 常量字段值
构造器详细资料
ScriptTemplateView
public ScriptTemplateView()
Constructor for use as a bean.
ScriptTemplateView
public ScriptTemplateView(String url)
Create a new ScriptTemplateView with the given URL.- 从以下版本开始:
- 4.2.1
方法详细资料
setEngine
public void setEngine(ScriptEngine engine)
SeeScriptTemplateConfigurer.setEngine(ScriptEngine)
documentation.
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.
setContentType
public void setContentType(String contentType)
SeeScriptTemplateConfigurer.setContentType(String)
} documentation.- 覆盖:
setContentType
在类中AbstractView
- 从以下版本开始:
- 4.2.1
setCharset
public void setCharset(Charset charset)
SeeScriptTemplateConfigurer.setCharset(Charset)
documentation.
setResourceLoaderPath
public void setResourceLoaderPath(String resourceLoaderPath)
SeeScriptTemplateConfigurer.setResourceLoaderPath(String)
documentation.
initApplicationContext
protected void initApplicationContext(ApplicationContext context)
从类复制的说明:WebApplicationObjectSupport
CallsWebApplicationObjectSupport.initServletContext(javax.servlet.ServletContext)
if the given ApplicationContext is aWebApplicationContext
.- 覆盖:
initApplicationContext
在类中WebApplicationObjectSupport
- 参数:
context
- the containing ApplicationContext- 另请参阅:
ApplicationObjectSupport.setApplicationContext(org.springframework.context.ApplicationContext)
getEngine
protected ScriptEngine getEngine()
createEngineFromName
protected ScriptEngine createEngineFromName()
loadScripts
protected void loadScripts(ScriptEngine engine)
getResource
protected Resource getResource(String location)
autodetectViewConfig
protected ScriptTemplateConfig autodetectViewConfig() throws BeansException
checkResource
public boolean checkResource(Locale locale) throws Exception
从类复制的说明:AbstractUrlBasedView
Check whether the underlying resource that the configured URL points to actually exists.- 覆盖:
checkResource
在类中AbstractUrlBasedView
- 参数:
locale
- the desired Locale that we're looking for- 返回:
true
if the resource exists (or is assumed to exist);false
if we know that it does not exist- 抛出:
Exception
- if the resource exists but is invalid (e.g. could not be parsed)
prepareResponse
protected void prepareResponse(HttpServletRequest request, HttpServletResponse response)
从类复制的说明:AbstractView
Prepare the given response for rendering.The default implementation applies a workaround for an IE bug when sending download content via HTTPS.
- 覆盖:
prepareResponse
在类中AbstractView
- 参数:
request
- current HTTP requestresponse
- current HTTP response
renderMergedOutputModel
protected void renderMergedOutputModel(Map<String,Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception
从类复制的说明:AbstractView
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.
- 指定者:
renderMergedOutputModel
在类中AbstractView
- 参数:
model
- combined output Map (nevernull
), with dynamic values taking precedence over static attributesrequest
- current HTTP requestresponse
- current HTTP response- 抛出:
Exception
- if rendering failed
getTemplate
protected String getTemplate(String path) throws IOException
- 抛出:
IOException