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.
org.springframework.web.servlet.view.AbstractView , org.springframework.web.servlet.view.InternalResourceView
| Modifier and Type | Field and Description |
|---|---|
| public static final String | PATH_VARIABLES
Name of the |
| public static final String | RESPONSE_STATUS_ATTRIBUTE
Name of the |
| public static final String | SELECTED_CONTENT_TYPE
The |
| Modifier and Type | Method and Description |
|---|---|
| public default String | Returns: the content type String (optionally including a character set), ornull if not predeterminedReturn the content type of the view, if predetermined. |
| public void | render(Map<String, ?>
a Map with name Strings as keys and corresponding model
objects as values (Map can also be model, HttpServletRequest null in case of empty model)current HTTP request request, HttpServletResponse he HTTP response we are building response)Render the view given the specified model. |
| PATH_VARIABLES | back to summary |
|---|---|
| public static final String PATH_VARIABLES Name of the Note This attribute is not required to be supported by all View implementations.
| |
| RESPONSE_STATUS_ATTRIBUTE | back to summary |
|---|---|
| public static final String RESPONSE_STATUS_ATTRIBUTE Name of the Note This attribute is not required to be supported by all View implementations.
| |
| SELECTED_CONTENT_TYPE | back to summary |
|---|---|
| public static final String SELECTED_CONTENT_TYPE The
| |
| getContentType | back to summary |
|---|---|
| public default String getContentType() Return the content type of the view, if predetermined. Can be used to check the view's content type upfront, i.e. before an actual rendering attempt. | |
| render | back to summary |
|---|---|
| public void render(Map<String, ?> 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.
| |