接口 View
- 所有已知子接口:
SmartView
- 所有已知实现类:
AbstractAtomFeedView,AbstractFeedView,AbstractJackson2View,AbstractPdfStamperView,AbstractPdfView,AbstractRssFeedView,AbstractTemplateView,AbstractUrlBasedView,AbstractView,AbstractXlsView,AbstractXlsxStreamingView,AbstractXlsxView,FreeMarkerView,GroovyMarkupView,InternalResourceView,JstlView,MappingJackson2JsonView,MappingJackson2XmlView,MarshallingView,RedirectView,ScriptTemplateView,XsltView
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.
- 从以下版本开始:
- 4.0 2022/1/29 11:07
- 作者:
- Rod Johnson, Arjen Poutsma, Rossen Stoyanchev, Harry Yang
- 另请参阅:
-
字段概要
字段修饰符和类型字段说明static final StringName of theRequestContextattribute that contains the response status code.static final StringTheMediaTypeselected during content negotiation, which may be more specific than the one the View is configured with. -
方法概要
修饰符和类型方法说明default StringReturn the content type of the view, if predetermined.voidrender(Map<String, ?> model, RequestContext context) Render the view given the specified model.
-
字段详细资料
-
RESPONSE_STATUS_ATTRIBUTE
Name of theRequestContextattribute that contains the response status code.Note: This attribute is not required to be supported by all View implementations.
-
SELECTED_CONTENT_TYPE
TheMediaTypeselected during content negotiation, which may be more specific than the one the View is configured with. For example: "application/vnd.example-v1+xml" vs "application/*+xml".
-
-
方法详细资料
-
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.
- 返回:
- the content type String (optionally including a character set),
or
nullif not predetermined
-
render
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.
- 参数:
model- a Map with name Strings as keys and corresponding model objects as values (Map can also benullin case of empty model)context- current HTTP request and response context- 抛出:
Exception- if rendering failed
-