public class GroovyMarkupView extends AbstractTemplateView
AbstractTemplateView
subclass based on Groovy XML/XHTML markup templates.
Spring's Groovy Markup Template support requires Groovy 2.3.1 and higher.
GroovyMarkupViewResolver
,
GroovyMarkupConfigurer
,
Groovy Markup Template engine documentationSPRING_MACRO_REQUEST_CONTEXT_ATTRIBUTE
DEFAULT_CONTENT_TYPE
logger
PATH_VARIABLES, RESPONSE_STATUS_ATTRIBUTE, SELECTED_CONTENT_TYPE
Constructor and Description |
---|
GroovyMarkupView() |
Modifier and Type | Method and Description |
---|---|
protected groovy.text.markup.MarkupTemplateEngine |
autodetectMarkupTemplateEngine()
Autodetect a MarkupTemplateEngine via the ApplicationContext.
|
boolean |
checkResource(Locale locale)
Check whether the underlying resource that the configured URL points to
actually exists.
|
protected groovy.text.Template |
getTemplate(String viewUrl)
Return a template compiled by the configured Groovy Markup template engine
for the given view URL.
|
protected void |
initApplicationContext(ApplicationContext context)
Invoked at startup.
|
protected void |
renderMergedTemplateModel(Map<String,Object> model,
HttpServletRequest request,
HttpServletResponse response)
Subclasses must implement this method to actually render the view.
|
void |
setTemplateEngine(groovy.text.markup.MarkupTemplateEngine engine)
Set the MarkupTemplateEngine to use in this view.
|
applyContentType, renderMergedOutputModel, setAllowRequestOverride, setAllowSessionOverride, setExposeRequestAttributes, setExposeSessionAttributes, setExposeSpringMacroHelpers
afterPropertiesSet, getUrl, isUrlRequired, setUrl, toString
addStaticAttribute, createMergedOutputModel, createRequestContext, createTemporaryOutputStream, exposeModelAsRequestAttributes, generatesDownloadContent, getAttributesMap, getBeanName, getContentType, getRequestContextAttribute, getRequestToExpose, getStaticAttributes, isExposePathVariables, prepareResponse, render, setAttributes, setAttributesCSV, setAttributesMap, setBeanName, setContentType, setExposeContextBeansAsAttributes, setExposedContextBeanNames, setExposePathVariables, setRequestContextAttribute, setResponseContentType, writeToResponse
getServletContext, getTempDir, getWebApplicationContext, initServletContext, isContextRequired, setServletContext
getApplicationContext, getMessageSourceAccessor, initApplicationContext, requiredContextClass, setApplicationContext
public void setTemplateEngine(groovy.text.markup.MarkupTemplateEngine engine)
If not set, the engine is auto-detected by looking up up a single
GroovyMarkupConfig
bean in the web application context and using
it to obtain the configured MarkupTemplateEngine
instance.
GroovyMarkupConfig
public boolean checkResource(Locale locale) throws Exception
AbstractUrlBasedView
checkResource
in class AbstractUrlBasedView
locale
- the desired Locale that we're looking fortrue
if the resource exists (or is assumed to exist);
false
if we know that it does not existException
- if the resource exists but is invalid (e.g. could not be parsed)protected void initApplicationContext(ApplicationContext context)
templateEngine
has
been manually set, this method looks up a GroovyMarkupConfig
bean
by type and uses it to obtain the Groovy Markup template engine.initApplicationContext
in class WebApplicationObjectSupport
context
- the containing ApplicationContextGroovyMarkupConfig
,
setTemplateEngine(groovy.text.markup.MarkupTemplateEngine)
protected groovy.text.markup.MarkupTemplateEngine autodetectMarkupTemplateEngine() throws BeansException
BeansException
protected void renderMergedTemplateModel(Map<String,Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception
AbstractTemplateView
renderMergedTemplateModel
in class AbstractTemplateView
model
- combined output Map, with request attributes and
session attributes merged into it if requiredrequest
- current HTTP requestresponse
- current HTTP responseException
- if rendering failed