站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > Spring Framework 2.0.5 API 文档英文版

ParameterizableViewController (Spring Framework API 2.0) - Spring Framework 2.0.5 API 文档英文版

The Spring Framework

org.springframework.web.servlet.mvc
Class ParameterizableViewController

java.lang.Object
  extended by org.springframework.context.support.ApplicationObjectSupport
      extended by org.springframework.web.context.support.WebApplicationObjectSupport
          extended by org.springframework.web.servlet.support.WebContentGenerator
              extended by org.springframework.web.servlet.mvc.AbstractController
                  extended by org.springframework.web.servlet.mvc.ParameterizableViewController
All Implemented Interfaces:
ApplicationContextAware, ServletContextAware, Controller

public class ParameterizableViewController
extends AbstractController

Trivial controller that always returns a named view. The view can be configured using an exposed configuration property. This controller offers an alternative to sending a request straight to a view such as a JSP. The advantage here is that the client is not exposed to the concrete view technology but rather just to the controller URL; the concrete view will be determined by the ViewResolver.

An alternative to the ParameterizableViewController is a MultiActionController, which can define a variety of handler methods that just return a plain ModelAndView instance for a given view name.

Workflow (and that defined by superclass):

  1. Request is received by the controller
  2. call to handleRequestInternal which just returns the view, named by the configuration property viewName. Nothing more, nothing less

Exposed configuration properties (and those defined by superclass):
name default description
viewName null the name of the view the viewResolver will use to forward to (if this property is not set, an exception will be thrown during initialization)

Author:
Rod Johnson, Juergen Hoeller

Field Summary
 
Fields inherited from class org.springframework.web.servlet.support.WebContentGenerator
METHOD_GET, METHOD_HEAD, METHOD_POST
 
Fields inherited from class org.springframework.context.support.ApplicationObjectSupport
logger
 
Constructor Summary
ParameterizableViewController()
           
 
Method Summary
 String getViewName()
          Return the name of the view to delegate to.
protected  ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
          Return a ModelAndView object with the specified view name.
protected  void initApplicationContext()
          Subclasses can override this for custom initialization behavior.
 void setViewName(String viewName)
          Set the name of the view to delegate to.
 
Methods inherited from class org.springframework.web.servlet.mvc.AbstractController
handleRequest, isSynchronizeOnSession, setSynchronizeOnSession
 
Methods inherited from class org.springframework.web.servlet.support.WebContentGenerator
applyCacheSeconds, applyCacheSeconds, cacheForSeconds, cacheForSeconds, checkAndPrepare, checkAndPrepare, getCacheSeconds, getSupportedMethods, isRequireSession, isUseCacheControlHeader, isUseExpiresHeader, preventCaching, setCacheSeconds, setRequireSession, setSupportedMethods, setUseCacheControlHeader, setUseExpiresHeader
 
Methods inherited from class org.springframework.web.context.support.WebApplicationObjectSupport
getServletContext, getTempDir, getWebApplicationContext, isContextRequired, setServletContext
 
Methods inherited from class org.springframework.context.support.ApplicationObjectSupport
getApplicationContext, getMessageSourceAccessor, requiredContextClass, setApplicationContext
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ParameterizableViewController

public ParameterizableViewController()
Method Detail

setViewName

public void setViewName(String viewName)
Set the name of the view to delegate to.


getViewName

public String getViewName()
Return the name of the view to delegate to.


initApplicationContext

protected void initApplicationContext()
Description copied from class: ApplicationObjectSupport
Subclasses can override this for custom initialization behavior. Gets called by setApplicationContext after setting the context instance.

Note: Does not get called on reinitialization of the context but rather just on first initialization of this object's context reference.

Overrides:
initApplicationContext in class ApplicationObjectSupport
See Also:
ApplicationObjectSupport.setApplicationContext(org.springframework.context.ApplicationContext)

handleRequestInternal

protected ModelAndView handleRequestInternal(HttpServletRequest request,
                                             HttpServletResponse response)
                                      throws Exception
Return a ModelAndView object with the specified view name.

Specified by:
handleRequestInternal in class AbstractController
Throws:
Exception
See Also:
getViewName()

The Spring Framework

Copyright © 2002-2007 The Spring Framework.