是否可以在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文件的情况下做到这一点?这将是一个很好的方式来减少一些样板文件。
https://stackoverflow.com/questions/5062586
复制相似问题