org.springframework.web.servlet.view
Class BeanNameViewResolver

java.lang.Object
  extended byorg.springframework.context.support.ApplicationObjectSupport
      extended byorg.springframework.web.context.support.WebApplicationObjectSupport
          extended byorg.springframework.web.servlet.view.BeanNameViewResolver
All Implemented Interfaces:
ApplicationContextAware, ViewResolver

public class BeanNameViewResolver
extends WebApplicationObjectSupport
implements ViewResolver

Simple implementation of ViewResolver that interprets a view name as bean name in the current application context, i.e. in the XML file of the executing DispatcherServlet.

This resolver can be handy for small applications, keeping all definitions ranging from controllers to views are in the same place. For normal applications, XmlViewResolver will be the better choice, as it separates the XML bean definitions in a dedicated views file. View beans should virtually never have references to any other application beans - such a separation will make this clear.

This ViewResolver does not support internationalization. Consider ResourceBundleViewResolver if you need to apply different view resources per locale.

Since:
18.06.2003
Author:
Juergen Hoeller
See Also:
XmlViewResolver, ResourceBundleViewResolver

Field Summary
 
Fields inherited from class org.springframework.context.support.ApplicationObjectSupport
logger
 
Constructor Summary
BeanNameViewResolver()
           
 
Method Summary
 View resolveViewName(java.lang.String viewName, java.util.Locale locale)
          Resolve the given view by name.
 
Methods inherited from class org.springframework.web.context.support.WebApplicationObjectSupport
getServletContext, getTempDir, getWebApplicationContext, requiredContextClass
 
Methods inherited from class org.springframework.context.support.ApplicationObjectSupport
getApplicationContext, getMessageSourceAccessor, initApplicationContext, setApplicationContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BeanNameViewResolver

public BeanNameViewResolver()
Method Detail

resolveViewName

public View resolveViewName(java.lang.String viewName,
                            java.util.Locale locale)
                     throws BeansException
Description copied from interface: ViewResolver
Resolve the given view by name.

Specified by:
resolveViewName in interface ViewResolver
Parameters:
viewName - name of the view to resolve
locale - Locale in which to resolve the view. ViewResolvers that support internationalization should respect this.
Throws:
BeansException


Copyright (C) 2003-2004 The Spring Framework Project.