Equivalent of mvc:default-servlet-handler in Spring annotation-based configuration?

After digging a bit deeper, I found out that this is a known problem and is addressed by annotation features in the upcoming Spring 3.1 I solved my problem with the following code: Configuration @Import(FeatureConfig. Class) class AppConfig { ... } @FeatureConfiguration class FeatureConfig { @Feature public MvcDefaultServletHandler defaultHandler() { return new MvcDefaultServletHandler(); } } This does require using the milestone version of spring, though, but it seems to be the cleanest and preferred way of handling this.

Note that as of M2 they've dropped @Feature in favour of individual @Enable* annotations. – Nick Oct 3 at 8:32.

If you are using Spring 3.1 with WebMvc, you can configure default servlet handling like this: @Configuration @EnableWebMvc public class MvcConfig extends WebMvcConfigurerAdapter { @Override public void configureDefaultServletHandling( DefaultServletHandlerConfigurer configurer) { configurer.enable(); } }.

Bean public DefaultServletHttpRequestHandler defaultServletHttpRequestHandler() { return new DefaultServletHttpRequestHandler(); } @Bean public SimpleUrlHandlerMapping simpleUrlHandlerMapping() { Map urlMap = new ManagedMap(); urlMap. Put("/**", defaultServletHandlerName); SimpleUrlHandlerMapping hm = new SimpleUrlHandlerMapping(); hm. SetUrlMap(urlMap); return hm; }.

– haxney Feb 28 at 17:52 Also, the DefaultServletHttpRequestHandler seems to take priority over my handler, so that serving static files works, but my own defined paths don't. – haxney Feb 28 at 18:04.

After digging a bit deeper, I found out that this is a known problem and is addressed by annotation features in the upcoming Spring 3.1 .

Up vote 1 down vote favorite share g+ share fb share tw.

Right now I have: @Configuration @ImportResource("classpath:/mvc-resources. Xml") class AppConfig { // Other configuration... } with just the following in my resources/mvc-resources. Xml: And it works as expected.

Is it possible to do this without importing an XML file? It would be a nice way to cut down on some boilerplate. Java spring spring-mvc link|improve this question asked Feb 21 '11 at 5:16haxney1,086312 88% accept rate.

After digging a bit deeper, I found out that this is a known problem and is addressed by annotation features in the upcoming Spring 3.1. I solved my problem with the following code: @Configuration @Import(FeatureConfig. Class) class AppConfig { ... } @FeatureConfiguration class FeatureConfig { @Feature public MvcDefaultServletHandler defaultHandler() { return new MvcDefaultServletHandler(); } } This does require using the milestone version of spring, though, but it seems to be the cleanest and preferred way of handling this.

Note that as of M2 they've dropped @Feature in favour of individual @Enable* annotations. – Nick Oct 3 '11 at 8:32.

I don't think you can do it out of the box, but you can probably copy what DefaultServletHandlerBeanDefinitionParser does: Create a Bean of type DefaultServletHttpRequestHandler and map it to the URL scheme /**. I'd say your Bean should subclass DefaultServletHttpRequestHandler and do the mapping in a @PostConstruct method.

– haxney Feb 28 '11 at 17:52 Also, the DefaultServletHttpRequestHandler seems to take priority over my handler, so that serving static files works, but my own defined paths don't. – haxney Feb 28 '11 at 18:04.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions