【发布时间】:2011-11-15 23:46:48
【问题描述】:
是否可以在AnnotationConfig(Web)ApplicationContext 中定义等效的<mvc:default-servlet-handler/>?现在我有:
@Configuration
@ImportResource("classpath:/mvc-resources.xml")
class AppConfig {
// Other configuration...
}
在我的resources/mvc-resources.xml 中只有以下内容:
<?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 文件的情况下执行此操作?这将是减少一些样板文件的好方法。
【问题讨论】:
标签: java spring spring-mvc