Get Started Using Spring MVC

Spring MVC框架详解:DispatcherServlet与web.xml配置
本文深入探讨了Spring MVC框架中的DispatcherServlet及其在web.xml文件中的配置方式,阐述了其作为前端控制器在Spring框架中的作用,以及如何实现与Spring ApplicationContext的完全集成。

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.


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值