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 AbstractTemplateView
SPRING_MACRO_REQUEST_CONTEXT_ATTRIBUTEFields inherited from class AbstractView
DEFAULT_CONTENT_TYPEFields inherited from class ApplicationObjectSupport
loggerFields inherited from interface View
PATH_VARIABLES, RESPONSE_STATUS_ATTRIBUTE, SELECTED_CONTENT_TYPE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected groovy.text.markup.MarkupTemplateEngineAutodetect a MarkupTemplateEngine via the ApplicationContext.booleancheckResource(Locale locale) Check whether the underlying resource that the configured URL points to actually exists.protected groovy.text.TemplategetTemplate(String viewUrl) Return a template compiled by the configured Groovy Markup template engine for the given view URL.protected voidinitApplicationContext(ApplicationContext context) Invoked at startup.protected voidrenderMergedTemplateModel(Map<String, Object> model, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Subclasses must implement this method to actually render the view.voidsetTemplateEngine(groovy.text.markup.MarkupTemplateEngine engine) Set the MarkupTemplateEngine to use in this view.Methods inherited from class AbstractTemplateView
applyContentType, renderMergedOutputModel, setAllowRequestOverride, setAllowSessionOverride, setExposeRequestAttributes, setExposeSessionAttributes, setExposeSpringMacroHelpersMethods inherited from class AbstractUrlBasedView
afterPropertiesSet, getUrl, isUrlRequired, setUrl, toStringMethods inherited from class 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, writeToResponseMethods inherited from class WebApplicationObjectSupport
getServletContext, getTempDir, getWebApplicationContext, initServletContext, isContextRequired, setServletContextMethods inherited from class 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
GroovyMarkupConfigbean in the web application context and using it to obtain the configuredMarkupTemplateEngineinstance.- See Also:
-
initApplicationContext
Invoked at startup. If notemplateEnginehas been manually set, this method looks up aGroovyMarkupConfigbean by type and uses it to obtain the Groovy Markup template engine.- Overrides:
initApplicationContextin 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:AbstractUrlBasedViewCheck whether the underlying resource that the configured URL points to actually exists.- Overrides:
checkResourcein classAbstractUrlBasedView- Parameters:
locale- the desired Locale that we're looking for- Returns:
trueif the resource exists (or is assumed to exist);falseif 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, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws ExceptionDescription copied from class:AbstractTemplateViewSubclasses must implement this method to actually render the view.- Specified by:
renderMergedTemplateModelin 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
-