# 7.1　Spring MVC 配置的替代方案

在第 5 章中，我们通过扩展 AbstractAnnotationConfigDispatcherServletInitializer 快速搭建了 Spring MVC 环境。在这个便利的基础类中，假设我们需要基本的 DispatcherServlet 和 ContextLoaderListener 环境，并且 Spring 配置是使用 Java 的，而不是 XML。

尽管对很多 Spring 应用来说，这是一种安全的假设，但是并不一定总能满足我们的要求。除了 DispatcherServlet 以外，我们可能还需要额外的 Servlet 和 Filter；我们可能还需要对 DispatcherServlet 本身做一些额外的配置；或者，如果我们需要将应用部署到 Servlet 3.0 之前的容器中，那么还需要将 DispatcherServlet 配置到传统的 web.xml 中。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://potoyang.gitbook.io/spring-in-action-v4/di-7-zhang-spring-mvc-de-gao-ji-ji-shu/untitled-5.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
