Top Description Fields Constructors Methods
org.springframework.web.servlet.view.groovy

public Class GroovyMarkupView

extends AbstractTemplateView
Class Inheritance
Imports
java.io.BufferedWriter, .IOException, java.util.Locale, .Map, groovy.text.Template, groovy.text.markup.MarkupTemplateEngine, jakarta.servlet.ServletException, jakarta.servlet.http.HttpServletRequest, .HttpServletResponse, org.springframework.beans.BeansException, org.springframework.beans.factory.BeanFactoryUtils, .NoSuchBeanDefinitionException, org.springframework.context.ApplicationContext, .ApplicationContextException, org.springframework.lang.Nullable, org.springframework.util.Assert, org.springframework.web.servlet.view.AbstractTemplateView

An AbstractTemplateView subclass based on Groovy XML/XHTML markup templates.

Spring's Groovy Markup Template support requires Groovy 2.3.1 and higher.

Authors
Brian Clozel, Rossen Stoyanchev
Since
4.1
See Also
GroovyMarkupViewResolver, GroovyMarkupConfigurer, Groovy Markup Template engine documentation

Field Summary

Modifier and TypeField and Description
private MarkupTemplateEngine
Inherited from org.springframework.web.servlet.view.AbstractTemplateView:
SPRING_MACRO_REQUEST_CONTEXT_ATTRIBUTE

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected MarkupTemplateEngine
autodetectMarkupTemplateEngine()

Autodetect a MarkupTemplateEngine via the ApplicationContext.

public boolean
checkResource(Locale
the desired Locale that we're looking for
locale
)

Overrides org.springframework.web.servlet.view.AbstractUrlBasedView.checkResource.

Check whether the underlying resource that the configured URL points to actually exists.

protected Template
getTemplate(String viewUrl)

Return a template compiled by the configured Groovy Markup template engine for the given view URL.

protected void
protected void
renderMergedTemplateModel(Map<String, Object>
combined output Map, with request attributes and session attributes merged into it if required
model
,
HttpServletRequest
current HTTP request
request
,
HttpServletResponse
current HTTP response
response
)

Implements abstract org.springframework.web.servlet.view.AbstractTemplateView.renderMergedTemplateModel.

Subclasses must implement this method to actually render the view.

public void
setTemplateEngine(MarkupTemplateEngine engine)

Set the MarkupTemplateEngine to use in this view.

Inherited from org.springframework.web.servlet.view.AbstractTemplateView:
applyContentTyperenderMergedOutputModelsetAllowRequestOverridesetAllowSessionOverridesetExposeRequestAttributessetExposeSessionAttributessetExposeSpringMacroHelpers

Field Detail

engineback to summary
private MarkupTemplateEngine engine
Annotations
@Nullable

Constructor Detail

GroovyMarkupViewback to summary
public GroovyMarkupView()

Method Detail

autodetectMarkupTemplateEngineback to summary
protected MarkupTemplateEngine autodetectMarkupTemplateEngine() throws BeansException

Autodetect a MarkupTemplateEngine via the ApplicationContext. Called if a MarkupTemplateEngine has not been manually configured.

checkResourceback to summary
public boolean checkResource(Locale locale) throws Exception

Overrides org.springframework.web.servlet.view.AbstractUrlBasedView.checkResource.

Doc from org.springframework.web.servlet.view.AbstractUrlBasedView.checkResource.

Check whether the underlying resource that the configured URL points to actually exists.

Parameters
locale:Locale

the desired Locale that we're looking for

Returns:boolean

true if the resource exists (or is assumed to exist); false if we know that it does not exist

Annotations
@Override
Exceptions
Exception:
if the resource exists but is invalid (e.g. could not be parsed)
getTemplateback to summary
protected Template getTemplate(String viewUrl) throws Exception

Return a template compiled by the configured Groovy Markup template engine for the given view URL.

initApplicationContextback to summary
protected void initApplicationContext(ApplicationContext context)

Overrides org.springframework.web.context.support.WebApplicationObjectSupport.initApplicationContext.

Invoked at startup. If no templateEngine has been manually set, this method looks up a GroovyMarkupConfig bean by type and uses it to obtain the Groovy Markup template engine.

Parameters
context:ApplicationContext

Doc from org.springframework.context.support.ApplicationObjectSupport.initApplicationContext.

the containing ApplicationContext

Annotations
@Override
See Also
GroovyMarkupConfig, setTemplateEngine(groovy.text.markup.MarkupTemplateEngine)
renderMergedTemplateModelback to summary
protected void renderMergedTemplateModel(Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception

Implements abstract org.springframework.web.servlet.view.AbstractTemplateView.renderMergedTemplateModel.

Doc from org.springframework.web.servlet.view.AbstractTemplateView.renderMergedTemplateModel.

Subclasses must implement this method to actually render the view.

Parameters
model:Map<String, Object>

combined output Map, with request attributes and session attributes merged into it if required

request:HttpServletRequest

current HTTP request

response:HttpServletResponse

current HTTP response

Annotations
@Override
Exceptions
Exception:
if rendering failed
setTemplateEngineback to summary
public void setTemplateEngine(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 configured MarkupTemplateEngine instance.

See Also
GroovyMarkupConfig