类 UrlBasedViewResolver

  • 所有已实现的接口:
    Aware, InitializingBean, ApplicationContextAware, Ordered, ViewResolver
    直接已知子类:
    FreeMarkerViewResolver, ScriptTemplateViewResolver

    public class UrlBasedViewResolver
    extends ViewResolverSupport
    implements ViewResolver, ApplicationContextAware, InitializingBean
    A ViewResolver that allows direct resolution of symbolic view names to URLs without explicit mapping definitions. This is useful if symbolic names match the names of view resources in a straightforward manner (i.e. the symbolic name is the unique part of the resource's filename), without the need for a dedicated mapping to be defined for each view.

    Supports AbstractUrlBasedView subclasses like FreeMarkerView. The view class for all views generated by this resolver can be specified via the "viewClass" property.

    View names can either be resource URLs themselves, or get augmented by a specified prefix and/or suffix. Exporting an attribute that holds the RequestContext to all views is explicitly supported.

    Example: prefix="templates/", suffix=".ftl", viewname=test -> "templates/test.ftl"

    As a special feature, redirect URLs can be specified via the "redirect:" prefix. E.g.: "redirect:myAction" will trigger a redirect to the given URL, rather than resolution as standard view name. This is typically used for redirecting to a controller URL after finishing a form workflow.

    Note: This class does not support localized resolution, i.e. resolving a symbolic view name to different resources depending on the current locale.

    从以下版本开始:
    5.0
    作者:
    Rossen Stoyanchev, Sebastien Deleuze, Juergen Hoeller, Sam Brannen