How is the right View chosen when it comes to the rendering phase?
How is the right View chosen when it comes to the rendering phase?
In Spring MVC, the correct view is chosen during the rendering phase through the use of a ViewResolver
. The process begins when the controller processes a request and returns a logical view name. This logical view name is then passed to the ViewResolver
, which is responsible for mapping this name to an actual view technology, such as a JSP file.
The ViewResolver
configuration determines how the logical view names are mapped to actual view paths. For example, the InternalResourceViewResolver
can be configured with a prefix and a suffix to resolve the view names to specific JSP paths. If a controller returns "hello" as a logical view name, and the InternalResourceViewResolver
is configured with a prefix of "/WEB-INF/views/" and a suffix of ".jsp", it would resolve the logical view name "hello" to the path "/WEB-INF/views/hello.jsp". The DispatcherServlet
then forwards the request to this JSP page for re...
middle
Gợi ý câu hỏi phỏng vấn
Chưa có bình luận nào