Package org.springframework.web.servlet.config.annotation

# Class UrlBasedViewResolverRegistration

java.lang.Object
org.springframework.web.servlet.config.annotation.UrlBasedViewResolverRegistration

public class UrlBasedViewResolverRegistration extends Object
Assist with configuring a `UrlBasedViewResolver`.

Since:
  4.1
Author:
  Sebastien Deleuze, Rossen Stoyanchev

## Field Summary

Fields
Modifier and Type
Field
Description
`protected final UrlBasedViewResolver`
`viewResolver`

## Constructor Summary

Constructors
Constructor
Description
`UrlBasedViewResolverRegistration(UrlBasedViewResolver viewResolver)`

## Method Summary

Modifier and Type
Method
Description
`UrlBasedViewResolverRegistration`
`attributes(Map<String,?> attributes)`
Set static attributes to be added to the model of every request for all views resolved by this view resolver.
`UrlBasedViewResolverRegistration`
`cache(boolean cache)`
Enable or disable caching.
`UrlBasedViewResolverRegistration`
`cacheLimit(int cacheLimit)`
Specify the maximum number of entries for the view cache.
`protected UrlBasedViewResolver`
`getViewResolver()`
`UrlBasedViewResolverRegistration`
`prefix(String prefix)`
Set the prefix that gets prepended to view names when building a URL.
`UrlBasedViewResolverRegistration`
`suffix(String suffix)`
Set the suffix that gets appended to view names when building a URL.
`UrlBasedViewResolverRegistration`
`viewClass(Class<?> viewClass)`
Set the view class that should be used to create views.
`UrlBasedViewResolverRegistration`
`viewNames(String... viewNames)`
Set the view names (or name patterns) that can be handled by this view resolver.

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

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

## Field Details

### viewResolver

protected final UrlBasedViewResolver viewResolver

## Constructor Details

### UrlBasedViewResolverRegistration

public UrlBasedViewResolverRegistration(UrlBasedViewResolver viewResolver)

## Method Details

### getViewResolver

protected UrlBasedViewResolver getViewResolver()

### prefix

public UrlBasedViewResolverRegistration prefix(String prefix)
Set the prefix that gets prepended to view names when building a URL.

See Also:
  - `UrlBasedViewResolver.setPrefix(java.lang.String)`

### suffix

public UrlBasedViewResolverRegistration suffix(String suffix)
Set the suffix that gets appended to view names when building a URL.

See Also:
  - `UrlBasedViewResolver.setSuffix(java.lang.String)`

### viewClass

public UrlBasedViewResolverRegistration viewClass(Class<?> viewClass)
Set the view class that should be used to create views.

See Also:
  - `UrlBasedViewResolver.setViewClass(java.lang.Class<?>)`

### viewNames

public UrlBasedViewResolverRegistration viewNames(String... viewNames)
Set the view names (or name patterns) that can be handled by this view resolver. View names can contain simple wildcards such that 'my*', '*Report' and '*Repo*' will all match the view name 'myReport'.

See Also:
  - `UrlBasedViewResolver.setViewNames(java.lang.String...)`

### attributes

public UrlBasedViewResolverRegistration attributes(Map<String,?> attributes)
Set static attributes to be added to the model of every request for all views resolved by this view resolver. This allows for setting any kind of attribute values, for example bean references.

See Also:
  - `UrlBasedViewResolver.setAttributesMap(java.util.Map<java.lang.String, ?>)`

### cacheLimit

public UrlBasedViewResolverRegistration cacheLimit(int cacheLimit)
Specify the maximum number of entries for the view cache. Default is 1024.

See Also:
  - `AbstractCachingViewResolver.setCache(boolean)`

### cache

public UrlBasedViewResolverRegistration cache(boolean cache)
Enable or disable caching.

This is equivalent to setting the `"cacheLimit"` property to the default limit (1024) or to 0, respectively.

Default is "true": caching is enabled. Disable this only for debugging and development.

See Also:
  - `AbstractCachingViewResolver.setCache(boolean)`