Overview | Package | Class | Tree | Deprecated | Index | Help
| Spring Framework
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.springframework.web.servlet
Interface View

All Known Subinterfaces:
  SmartView

All Known Implementing Classes:
  AbstractAtomFeedView, AbstractExcelView, AbstractFeedView, AbstractJasperReportsSingleFormatView, AbstractJasperReportsView, AbstractJExcelView, AbstractPdfStamperView, AbstractPdfView, AbstractRssFeedView, AbstractTemplateView, AbstractUrlBasedView, AbstractView, AbstractXsltView, ConfigurableJasperReportsView, FreeMarkerView, InternalResourceView, JasperReportsCsvView, JasperReportsHtmlView, JasperReportsMultiFormatView, JasperReportsPdfView, JasperReportsXlsView, JstlView, MappingJackson2JsonView, MappingJacksonJsonView, MarshallingView, RedirectView, TilesJstlView, TilesView, 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, Arjen Poutsma
See Also:
  `AbstractView`, `InternalResourceView`

Field Summary
`static java.lang.String` | `PATH_VARIABLES` Name of the `HttpServletRequest` attribute that contains a Map with path variables.
`static java.lang.String` | `RESPONSE_STATUS_ATTRIBUTE` Name of the `HttpServletRequest` attribute that contains the response status code.

Method Summary
`java.lang.String` | `getContentType()` Return the content type of the view, if predetermined.
`void` | `render(java.util.Map<java.lang.String,?> model, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)` Render the view given the specified model.

Field Detail

### RESPONSE_STATUS_ATTRIBUTE

    static final java.lang.String RESPONSE_STATUS_ATTRIBUTE

  Name of the `HttpServletRequest` attribute that contains the response status code.

  Note: This attribute is not required to be supported by all View implementations.

### PATH_VARIABLES

    static final java.lang.String PATH_VARIABLES

  Name of the `HttpServletRequest` attribute that contains a Map with path variables. The map consists of String-based URI template variable names as keys and their corresponding Object-based values -- extracted from segments of the URL and type converted.

  Note: This attribute is not required to be supported by all View implementations.

Method Detail

### getContentType

    java.lang.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(java.util.Map<java.lang.String,?> model,
                javax.servlet.http.HttpServletRequest request,
                javax.servlet.http.HttpServletResponse response)
                throws java.lang.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:
    `java.lang.Exception` - if rendering failed

Overview | Package | Class | Tree | Deprecated | Index | Help
| Spring Framework
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD