首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >是否等同于Spring基于注释的配置中的mvc:default-servlet-handler?

是否等同于Spring基于注释的配置中的mvc:default-servlet-handler?
EN

Stack Overflow用户
提问于 2011-02-21 13:16:20
回答 4查看 10.9K关注 0票数 18

是否可以在AnnotationConfig(Web)ApplicationContext中定义<mvc:default-servlet-handler/>的等价物?现在我有:

代码语言:javascript
运行
复制
@Configuration
@ImportResource("classpath:/mvc-resources.xml")
class AppConfig {
  // Other configuration...
}

在我的resources/mvc-resources.xml中只有以下内容

代码语言:javascript
运行
复制
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="
        http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/mvc
        http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<mvc:default-servlet-handler/>
</beans>

它的工作方式和预期的一样。有没有可能在不导入XML文件的情况下做到这一点?这将是一个很好的方式来减少一些样板文件。

EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/5062586

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档