Spring's web MVC framework is,
a request-driven web MVC framework, designed around a servlet that dispatches requests to controllers and offers many other functionality for the development of web applications. Spring's DispatcherServlet is completely integrated with the Spring ApplicationContext
and allows you to use every other feature of springs as well.
Spring uses a Front Controller like many of the other leading MVC architectures. The Front Controller in Spring is called DispatcherServlet and is declared in the web.xml file. In this example, Spring sets up the following declaration for the DispatcherServlet:
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
The file includes a basic reference to the servlet class and the configuration file for the servlet located in the /WEB-INF/spring/appServlet/ folder. Unlike other MVC architectures, Spring's dispatcher servlet has full access to the container (i.e., the Spring container)
The servlet-context.xml file contains the Bean properties for the beans that Spring uses to resolve view, locale, theme, and multi-part file resolvers. Most of the time, these beans and their properties are pre-configured for you with the necessary values.
本文深入探讨了Spring MVC框架中的DispatcherServlet及其在web.xml文件中的配置方式,阐述了其作为前端控制器在Spring框架中的作用,以及如何实现与Spring ApplicationContext的完全集成。
1477

被折叠的 条评论
为什么被折叠?



