【发布时间】:2011-12-08 22:09:53
【问题描述】:
我正在使用注释构建一个项目来完成配置工作。
当我这样做时,我找不到使用注释来替换 mvc:resources 命名空间标记的方法。
我可以举例说明我想要什么。
示例:使用注解替换<mvc:annotation-driven />。
@Configuration
@Lazy(false)
public class MVCContainerConfig
{
/**
* Define (MVC) Annotation Method Handler Adapter. (Same as <mvc:annotation-driven /> in XML)
*/
@Bean
public AnnotationMethodHandlerAdapter annotationMethodHandlerAdapter()
{
ConfigurableWebBindingInitializer configurableWebBindingInitializer = new ConfigurableWebBindingInitializer();
configurableWebBindingInitializer.setValidator(localValidatorFactoryBean());
AnnotationMethodHandlerAdapter annotationMethodHandlerAdapter = new AnnotationMethodHandlerAdapter();
annotationMethodHandlerAdapter.setWebBindingInitializer(configurableWebBindingInitializer);
annotationMethodHandlerAdapter.setMessageConverters(new HttpMessageConverter[]{
new BufferedImageHttpMessageConverter(),
new ByteArrayHttpMessageConverter(),
new FormHttpMessageConverter(),
new ResourceHttpMessageConverter(),
new StringHttpMessageConverter(),
new AtomFeedHttpMessageConverter(),
new RssChannelHttpMessageConverter(),
new MappingJacksonHttpMessageConverter(),
new Jaxb2RootElementHttpMessageConverter(),
new MarshallingHttpMessageConverter(),
new XmlAwareFormHttpMessageConverter()
});
return annotationMethodHandlerAdapter;
}
... ...
}
那么基于上面的例子,有没有办法使用注解来替换<mvc:resources />命名空间标签呢?
提前致谢!
【问题讨论】:
标签: xml spring resources annotations spring-webflow