org.springframework.web.servlet.view.groovy

## Class GroovyMarkupViewResolver

- java.lang.Object
- - org.springframework.context.support.ApplicationObjectSupport
  - - org.springframework.web.context.support.WebApplicationObjectSupport
    - - org.springframework.web.servlet.view.AbstractCachingViewResolver
      - - org.springframework.web.servlet.view.UrlBasedViewResolver
        - - org.springframework.web.servlet.view.AbstractTemplateViewResolver
          - - org.springframework.web.servlet.view.groovy.GroovyMarkupViewResolver

- All Implemented Interfaces:
    Aware, ApplicationContextAware, Ordered, ServletContextAware, ViewResolver

      public class GroovyMarkupViewResolver
      extends AbstractTemplateViewResolver

  Convenience subclass of `AbstractTemplateViewResolver` that supports `GroovyMarkupView` (i.e. Groovy XML/XHTML markup templates) and custom subclasses of it.

  The view class for all views created by this resolver can be specified via `UrlBasedViewResolver.setViewClass(Class)`.

  Note: When chaining ViewResolvers this resolver will check for the existence of the specified template resources and only return a non-null `View` object if a template is actually found.

  Since:
    4.1
  Author:
    Brian Clozel
  See Also:
    `GroovyMarkupConfigurer`

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from class org.springframework.web.servlet.view.AbstractCachingViewResolver

      `AbstractCachingViewResolver.CacheFilter`

  - ### Field Summary

    - ### Fields inherited from class org.springframework.web.servlet.view.UrlBasedViewResolver

      `FORWARD_URL_PREFIX, REDIRECT_URL_PREFIX`

    - ### Fields inherited from class org.springframework.web.servlet.view.AbstractCachingViewResolver

      `DEFAULT_CACHE_LIMIT`

    - ### Fields inherited from class org.springframework.context.support.ApplicationObjectSupport

      `logger`

    - ### Fields inherited from interface org.springframework.core.Ordered

      `HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `GroovyMarkupViewResolver()` Sets the default `view class` to `requiredViewClass()`: by default `GroovyMarkupView`.
    `GroovyMarkupViewResolver(String prefix, String suffix)` A convenience constructor that allows for specifying the `prefix` and `suffix` as constructor arguments.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected Object` | `getCacheKey(String viewName, Locale locale)` This resolver supports i18n, so cache keys should contain the locale.
    `protected AbstractUrlBasedView` | `instantiateView()` Instantiate the specified view class.
    `protected Class<?>` | `requiredViewClass()` Return the required type of view for this resolver.

    - ### Methods inherited from class org.springframework.web.servlet.view.AbstractTemplateViewResolver

      `buildView, setAllowRequestOverride, setAllowSessionOverride, setExposeRequestAttributes, setExposeSessionAttributes, setExposeSpringMacroHelpers`

    - ### Methods inherited from class org.springframework.web.servlet.view.UrlBasedViewResolver

      `applyLifecycleMethods, canHandle, createView, getAttributesMap, getContentType, getExposeContextBeansAsAttributes, getExposedContextBeanNames, getExposePathVariables, getOrder, getPrefix, getRedirectHosts, getRequestContextAttribute, getSuffix, getViewClass, getViewNames, initApplicationContext, isRedirectContextRelative, isRedirectHttp10Compatible, loadView, setAttributes, setAttributesMap, setContentType, setExposeContextBeansAsAttributes, setExposedContextBeanNames, setExposePathVariables, setOrder, setPrefix, setRedirectContextRelative, setRedirectHosts, setRedirectHttp10Compatible, setRequestContextAttribute, setSuffix, setViewClass, setViewNames`

    - ### Methods inherited from class org.springframework.web.servlet.view.AbstractCachingViewResolver

      `clearCache, getCacheFilter, getCacheLimit, isCache, isCacheUnresolved, removeFromCache, resolveViewName, setCache, setCacheFilter, setCacheLimit, setCacheUnresolved`

    - ### Methods inherited from class org.springframework.web.context.support.WebApplicationObjectSupport

      `getServletContext, getTempDir, getWebApplicationContext, initApplicationContext, initServletContext, isContextRequired, setServletContext`

    - ### Methods inherited from class org.springframework.context.support.ApplicationObjectSupport

      `getApplicationContext, getMessageSourceAccessor, obtainApplicationContext, requiredContextClass, setApplicationContext`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### GroovyMarkupViewResolver

          public GroovyMarkupViewResolver()

      Sets the default `view class` to `requiredViewClass()`: by default `GroovyMarkupView`.

    - #### GroovyMarkupViewResolver

          public GroovyMarkupViewResolver(String prefix,
                                          String suffix)

      A convenience constructor that allows for specifying the `prefix` and `suffix` as constructor arguments.
      Parameters:
        `prefix` - the prefix that gets prepended to view names when building a URL
        `suffix` - the suffix that gets appended to view names when building a URL
      Since:
        4.3

  - ### Method Detail

    - #### requiredViewClass

          protected Class<?> requiredViewClass()

      Description copied from class: `UrlBasedViewResolver`
      Return the required type of view for this resolver. This implementation returns `AbstractUrlBasedView`.
      Overrides:
        `requiredViewClass` in class `AbstractTemplateViewResolver`
      See Also:
        `UrlBasedViewResolver.instantiateView()`, `AbstractUrlBasedView`

    - #### instantiateView

          protected AbstractUrlBasedView instantiateView()

      Description copied from class: `UrlBasedViewResolver`
      Instantiate the specified view class.

      The default implementation uses reflection to instantiate the class.

      Overrides:
        `instantiateView` in class `UrlBasedViewResolver`
      Returns:
        a new instance of the view class
      See Also:
        `UrlBasedViewResolver.setViewClass(java.lang.Class<?>)`

    - #### getCacheKey

          protected Object getCacheKey(String viewName,
                                       Locale locale)

      This resolver supports i18n, so cache keys should contain the locale.
      Overrides:
        `getCacheKey` in class `UrlBasedViewResolver`