Class GroovyMarkupView
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.AbstractTemplateView
org.springframework.web.servlet.view.groovy.GroovyMarkupView
- All Implemented Interfaces:
Aware
,BeanNameAware
,InitializingBean
,ApplicationContextAware
,ServletContextAware
,View
An
AbstractTemplateView
subclass based on Groovy XML/XHTML markup templates.
Spring's Groovy Markup Template support requires Groovy 2.3.1 and higher.
- Since:
- 4.1
- Author:
- Brian Clozel, Rossen Stoyanchev
- See Also:
-
Field Summary
Fields inherited from class org.springframework.web.servlet.view.AbstractTemplateView
SPRING_MACRO_REQUEST_CONTEXT_ATTRIBUTE
Fields inherited from class org.springframework.web.servlet.view.AbstractView
DEFAULT_CONTENT_TYPE
Fields inherited from class org.springframework.context.support.ApplicationObjectSupport
logger
Fields inherited from interface org.springframework.web.servlet.View
PATH_VARIABLES, RESPONSE_STATUS_ATTRIBUTE, SELECTED_CONTENT_TYPE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected groovy.text.markup.MarkupTemplateEngine
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.Methods inherited from class org.springframework.web.servlet.view.AbstractTemplateView
applyContentType, renderMergedOutputModel, setAllowRequestOverride, setAllowSessionOverride, setExposeRequestAttributes, setExposeSessionAttributes, setExposeSpringMacroHelpers
Methods inherited from class org.springframework.web.servlet.view.AbstractUrlBasedView
afterPropertiesSet, getUrl, isUrlRequired, setUrl, toString
Methods inherited from class org.springframework.web.servlet.view.AbstractView
addStaticAttribute, createMergedOutputModel, createRequestContext, createTemporaryOutputStream, exposeModelAsRequestAttributes, formatViewName, generatesDownloadContent, getAttributesMap, getBeanName, getContentType, getRequestContextAttribute, getRequestToExpose, getStaticAttributes, isExposePathVariables, prepareResponse, render, setAttributes, setAttributesCSV, setAttributesMap, setBeanName, setContentType, setExposeContextBeansAsAttributes, setExposedContextBeanNames, setExposePathVariables, setRequestContextAttribute, setResponseContentType, writeToResponse
Methods inherited from class org.springframework.web.context.support.WebApplicationObjectSupport
getServletContext, getTempDir, getWebApplicationContext, initServletContext, isContextRequired, setServletContext
Methods inherited from class org.springframework.context.support.ApplicationObjectSupport
getApplicationContext, getMessageSourceAccessor, initApplicationContext, obtainApplicationContext, requiredContextClass, setApplicationContext
-
Constructor Details
-
GroovyMarkupView
public GroovyMarkupView()
-
-
Method Details
-
setTemplateEngine
public void setTemplateEngine(groovy.text.markup.MarkupTemplateEngine engine) Set the MarkupTemplateEngine to use in this view.If not set, the engine is auto-detected by looking up a single
GroovyMarkupConfig
bean in the web application context and using it to obtain the configuredMarkupTemplateEngine
instance.- See Also:
-
initApplicationContext
Invoked at startup. If notemplateEngine
has been manually set, this method looks up aGroovyMarkupConfig
bean by type and uses it to obtain the Groovy Markup template engine.- Overrides:
initApplicationContext
in classWebApplicationObjectSupport
- Parameters:
context
- the containing ApplicationContext- See Also:
-
autodetectMarkupTemplateEngine
protected groovy.text.markup.MarkupTemplateEngine autodetectMarkupTemplateEngine() throws BeansExceptionAutodetect a MarkupTemplateEngine via the ApplicationContext. Called if a MarkupTemplateEngine has not been manually configured.- Throws:
BeansException
-
checkResource
Description copied from class:AbstractUrlBasedView
Check whether the underlying resource that the configured URL points to actually exists.- Overrides:
checkResource
in classAbstractUrlBasedView
- Parameters:
locale
- the desired Locale that we're looking for- Returns:
true
if the resource exists (or is assumed to exist);false
if we know that it does not exist- Throws:
Exception
- if the resource exists but is invalid (for example, could not be parsed)
-
renderMergedTemplateModel
protected void renderMergedTemplateModel(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws ExceptionDescription copied from class:AbstractTemplateView
Subclasses must implement this method to actually render the view.- Specified by:
renderMergedTemplateModel
in classAbstractTemplateView
- Parameters:
model
- combined output Map, with request attributes and session attributes merged into it if requiredrequest
- current HTTP requestresponse
- current HTTP response- Throws:
Exception
- if rendering failed
-
getTemplate
Return a template compiled by the configured Groovy Markup template engine for the given view URL.- Throws:
Exception
-