此版本仍在开发中,尚未被视为稳定版本。对于最新的稳定版本,请使用 Spring Framework 6.2.0spring-doc.cadn.net.cn

MVC 配置 API

在 Java 配置中,您可以实现WebMvcConfigurer接口,作为 以下示例显示:spring-doc.cadn.net.cn

@Configuration
@EnableWebMvc
public class WebConfig implements WebMvcConfigurer {

	// Implement configuration methods...
}
@Configuration
@EnableWebMvc
class WebConfig : WebMvcConfigurer {

	// Implement configuration methods...
}

在 XML 中,您可以检查<mvc:annotation-driven/>.您可以 查看 Spring MVC XML 模式或使用 IDE 的代码补全功能,用于发现哪些属性和 子元素可用。spring-doc.cadn.net.cn