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

View (Spring Framework API 2.1) - Spring Framework 2.1.0 API 文档英文版


The Spring Framework

org.springframework.web.servlet
Interface View

All Known Implementing Classes:
AbstractExcelView, AbstractJasperReportsSingleFormatView, AbstractJasperReportsView, AbstractJExcelView, AbstractPdfView, AbstractTemplateView, AbstractUrlBasedView, AbstractView, AbstractXsltView, ConfigurableJasperReportsView, FreeMarkerView, InternalResourceView, JasperReportsCsvView, JasperReportsHtmlView, JasperReportsMultiFormatView, JasperReportsPdfView, JasperReportsXlsView, JstlView, RedirectView, TilesJstlView, TilesView, VelocityLayoutView, VelocityToolboxView, VelocityView, XsltView

public interface View

MVC View for a web interaction. Implementations are responsible for rendering content, and exposing the model. A single view exposes multiple model attributes.

This class and the MVC approach associated with it is discussed in Chapter 12 of Expert One-On-One J2EE Design and Development by Rod Johnson (Wrox, 2002).

View implementations may differ widely. An obvious implementation would be JSP-based. Other implementations might be XSLT-based, or use an HTML generation library. This interface is designed to avoid restricting the range of possible implementations.

Views should be beans. They are likely to be instantiated as beans by a ViewResolver. As this interface is stateless, view implementations should be thread-safe.

Author:
Rod Johnson
See Also:
AbstractView, InternalResourceView

Method Summary
 String getContentType()
          Return the content type of the view, if predetermined.
 void render(Map model, HttpServletRequest request, HttpServletResponse response)
          Render the view given the specified model.
 

Method Detail

getContentType

String getContentType()
Return the content type of the view, if predetermined.

Can be used to check the content type upfront, before the actual rendering process.

Returns:
the content type String (optionally including a character set), or null if not predetermined.

render

void render(Map model,
            HttpServletRequest request,
            HttpServletResponse response)
            throws Exception
Render the view given the specified model.

The first step will be preparing the request: In the JSP case, this would mean setting model objects as request attributes. The second step will be the actual rendering of the view, for example including the JSP via a RequestDispatcher.

Parameters:
model - Map with name Strings as keys and corresponding model objects as values (Map can also be null in case of empty model)
request - current HTTP request
response - HTTP response we are building
Throws:
Exception - if rendering failed

The Spring Framework

Copyright © 2002-2007 The Spring Framework.